Make WordPress Core

Changeset 26665


Ignore:
Timestamp:
12/05/2013 08:20:03 AM (11 years ago)
Author:
lancewillett
Message:

Twenty Fourteen: fix two usability issues with touch events on mobile devices with the Featured Content slider:

  • Try to avoid the slight delay when swiping from one slide to the next.
  • Fix bug where second to last slide was animating like it was the last.

Fixes #26191.

Location:
trunk/src/wp-content/themes/twentyfourteen
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-content/themes/twentyfourteen/functions.php

    r26657 r26665  
    256256
    257257    if ( is_front_page() && 'slider' == get_theme_mod( 'featured_content_layout' ) ) {
    258         wp_enqueue_script( 'twentyfourteen-slider', get_template_directory_uri() . '/js/slider.js', array( 'jquery' ), '20131109', true );
     258        wp_enqueue_script( 'twentyfourteen-slider', get_template_directory_uri() . '/js/slider.js', array( 'jquery' ), '20131205', true );
    259259        wp_localize_script( 'twentyfourteen-slider', 'featuredSliderDefaults', array(
    260260            'prevText' => __( 'Previous', 'twentyfourteen' ),
  • trunk/src/wp-content/themes/twentyfourteen/js/slider.js

    r26606 r26665  
    4040                slider.isRtl = $( 'body' ).hasClass( 'rtl' );
    4141                slider.args = {};
     42                slider.limit = 0;
    4243                // TOUCH
    4344                slider.transitions = ( function() {
     
    7778                            target = false;
    7879                        if ( ! slider.animating && ( keycode === 39 || keycode === 37 ) ) {
    79                             if (keycode === 39){
     80                            if ( keycode === 39 ) {
    8081                                target = slider.getTarget( 'next' );
    81                             } else if (keycode === 37) {
     82                            } else if ( keycode === 37 ) {
    8283                                target = slider.getTarget( 'prev' );
    8384                            }
     
    244245                        localY = e.touches[0].pageY;
    245246
    246                         offset = ( slider.animatingTo === slider.last ) ? 0 :
    247                                 ( slider.currentSlide === slider.last ) ? slider.limit : ( slider.currentSlide + slider.cloneOffset ) * cwidth;
     247                        offset = ( slider.currentSlide + slider.cloneOffset ) * cwidth;
     248                        if ( slider.animatingTo === slider.last && slider.direction !== 'next' ) {
     249                            offset = 0;
     250                        }
     251
    248252                        startX = localX;
    249253                        startY = localY;
     
    262266                    scrolling = Math.abs( dx ) < Math.abs( localY - startY );
    263267
    264                     var fxms = 500;
    265 
    266                     if ( ! scrolling || Number( new Date() ) - startT > fxms ) {
     268                    if ( ! scrolling ) {
    267269                        e.preventDefault();
    268270                        if ( slider.transitions ) {
     
    299301                        cwidth = slider.w;
    300302                        startT = Number( new Date() );
    301                         offset = ( slider.animatingTo === slider.last ) ? 0 : ( slider.currentSlide === slider.last ) ? slider.limit : ( slider.currentSlide + slider.cloneOffset ) * cwidth;
     303                        offset = ( slider.currentSlide + slider.cloneOffset ) * cwidth;
     304                        if ( slider.animatingTo === slider.last && slider.direction !== 'next' ) {
     305                            offset = 0;
     306                        }
    302307                    }
    303308                }
Note: See TracChangeset for help on using the changeset viewer.