Viewing 2 replies - 1 through 2 (of 2 total)
  • Hey:
    You are not specific what content you wish to do with the slider. I have created a free slider:
    https://github.com/PHuhn/WordPress-Child-Theme-Addons

    In general, all content div’s are set to display none and then the JavaScript loops through and set to be displayed. All animation is handled by the built in CSS animation.

    Phil

    JavaScript Code:

    var gc_sliders = document.querySelectorAll( '.gc-slider' );
    /**
    ** Get all sliders, loop through the items and set display
    ** to none and block.  The slider has the following:
    ** slider
    **   header
    **   items
    **     item #0
    **     ...
    **     item #n
    **   footer
    **   counter
    */
    if( gc_sliders.length > 0 ) {
    	Array.prototype.forEach.call( gc_sliders, function( gc_slider ) {
    		var millisec = parseInt( gc_slider.dataset.millisec );
    		var items = gc_slider.children[1];
    		var count = items.children.length - 1;
    		var counter = gc_slider.children[3];
    		// process first slider item without delay
    		var idx = gc_slider_shift( gc_slider, items, millisec, count, count, 'table' );
    		gc_slider_counter( counter, idx, count );
    		var interval = setInterval( function() {
    			idx = gc_slider_shift( gc_slider, items, millisec, idx, count, 'table' );
    			gc_slider_counter( counter, idx, count );
    		}, millisec );
    	} );
    }
    /**
    ** Function: gc_slider_shift
    ** Turns off the display of the current child and moves to the 
    ** next child and turns that item to display on.
    ** @param {*} gc_slider: dom element with gc-slider class
    ** @param {*} items:     dom elements of slide-items of gc-slider element
    ** @param {*} millisec:  timeout interval
    ** @param {*} idx:       the current index (idx of count)
    ** @param {*} count:     the total count of slides (idx of count)
    ** @param {*} display:   display type, currently 'table'
    * @returns 
    */
    function gc_slider_shift( gc_slider, items, millisec, idx, count, display ) {
    	if ( gc_slider.classList.contains('gc-paused') === false ) {
    		items.children[idx].style.display = 'none';
    		idx = ( idx === count ? 0 : ++idx );
    		items.children[idx].style.display = display;
    		// console.log( <code>${gc_slider.id} ${idx}, ${millisec}, ${count}</code> );
    	}
    	return idx;
    }
    /**
    ** Function: gc_slider_counter
    ** Construct the display of the counter of "# of #", example "1 of 3"
    ** @param {*} gc_slider: dom element with gc-slider class
    ** @param {*} idx:       the current index (idx of count)
    ** @param {*} count:     the total count of slides (idx of count)
    ** @returns idx that was passed
    */
    function gc_slider_counter( gc_slider, idx, count ) {
    	gc_slider.innerHTML = <code>${idx + 1} of ${count + 1}</code>;
    	return idx;
    }
    /**
    ** Function: gc_slider_hover
    ** Add a class of paused to the element.  Aria requirement to be able
    ** to pause the slider/carousel.
    ** @param {*} element: dom hovered element with gc-slider class
    ** @returns false
    */
    function gc_slider_hover( element ) {
    	element.classList.add('gc-paused');
    	return false;
    }
    /**
    ** Function: gc_slider_hover_leave
    ** Remove a class of paused to the element.
    ** @param {*} element: dom hovered element with gc-slider class
    ** @returns false
    */
    function gc_slider_hover_leave( element ) {
    	element.classList.remove('gc-paused');
    	return false;
    }
    Thread Starter fanguro

    (@fanguro)

    Hey thanks for your help

    I did it quickly with the Revolution Slider for example

    https://www.morgenmut.com/icon-test/

    Missing:
    the blur effekt over the “not active Section” & and the Active Section should stay without blur (in my case the black layer)

    Do you now know how I want the slider?

    Best regards

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to do THIS slider’ is closed to new replies.