Changeset 54374
- Timestamp:
- 10/04/2022 01:41:59 AM (2 years ago)
- Location:
- trunk/src/wp-content/themes/twentyseventeen
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-content/themes/twentyseventeen/assets/js/jquery.scrollTo.js
r46586 r54374 1 1 /*! 2 2 * jQuery.scrollTo 3 * Copyright (c) 2007 -2015 Ariel Flesler - aflesler<a>gmail<d>com | http://flesler.blogspot.com3 * Copyright (c) 2007 Ariel Flesler - aflesler ○ gmail • com | https://github.com/flesler 4 4 * Licensed under MIT 5 * http ://flesler.blogspot.com/2007/10/jqueryscrollto.html5 * https://github.com/flesler/jquery.scrollTo 6 6 * @projectDescription Lightweight, cross-browser and highly customizable animated scrolling with jQuery 7 7 * @author Ariel Flesler 8 * @version 2.1. 28 * @version 2.1.3 9 9 */ 10 10 ;(function(factory) { … … 12 12 if (typeof define === 'function' && define.amd) { 13 13 // AMD 14 define( ['jquery'], factory);14 define(['jquery'], factory); 15 15 } else if (typeof module !== 'undefined' && module.exports) { 16 16 // CommonJS 17 module.exports = factory( require( 'jquery' ));17 module.exports = factory(require('jquery')); 18 18 } else { 19 19 // Global 20 factory( jQuery);20 factory(jQuery); 21 21 } 22 22 })(function($) { … … 24 24 25 25 var $scrollTo = $.scrollTo = function(target, duration, settings) { 26 return $( window ).scrollTo( target, duration, settings);26 return $(window).scrollTo(target, duration, settings); 27 27 }; 28 28 … … 34 34 35 35 function isWin(elem) { 36 return ! elem.nodeName || 37 $.inArray( elem.nodeName.toLowerCase(), ['iframe','#document','html','body'] ) !== -1; 36 return !elem.nodeName || 37 $.inArray(elem.nodeName.toLowerCase(), ['iframe','#document','html','body']) !== -1; 38 } 39 40 function isFunction(obj) { 41 // Brought from jQuery since it's deprecated 42 return typeof obj === 'function' 38 43 } 39 44 … … 50 55 } 51 56 52 settings = $.extend( {}, $scrollTo.defaults, settings);57 settings = $.extend({}, $scrollTo.defaults, settings); 53 58 // Speed is still recognized for backwards compatibility 54 59 duration = duration || settings.duration; … … 59 64 duration /= 2; 60 65 } 61 settings.offset = both( settings.offset);62 settings.over = both( settings.over);66 settings.offset = both(settings.offset); 67 settings.over = both(settings.over); 63 68 64 69 return this.each(function() { 65 70 // Null target yields nothing, just like jQuery does 66 if (target === null) { return; }67 68 var win = isWin( this),71 if (target === null) return; 72 73 var win = isWin(this), 69 74 elem = win ? this.contentWindow || window : this, 70 $elem = $( elem),75 $elem = $(elem), 71 76 targ = target, 72 77 attr = {}, … … 77 82 case 'number': 78 83 case 'string': 79 if (/^([+-]=?)?\d+(\.\d+)?(px|%)?$/.test( targ)) {80 targ = both( targ);84 if (/^([+-]=?)?\d+(\.\d+)?(px|%)?$/.test(targ)) { 85 targ = both(targ); 81 86 // We are done 82 87 break; 83 88 } 84 89 // Relative/Absolute selector 85 targ = win ? $( targ ) : $( targ, elem);90 targ = win ? $(targ) : $(targ, elem); 86 91 /* falls through */ 87 92 case 'object': 88 if (targ.length === 0) { return; }93 if (targ.length === 0) return; 89 94 // DOMElement / jQuery 90 95 if (targ.is || targ.style) { 91 96 // Get the real position of the target 92 toff = (targ = $( targ)).offset();93 } 94 } 95 96 var offset = $.isFunction( settings.offset ) && settings.offset( elem, targ) || settings.offset;97 98 $.each(settings.axis.split( ''), function(i, axis) {97 toff = (targ = $(targ)).offset(); 98 } 99 } 100 101 var offset = isFunction(settings.offset) && settings.offset(elem, targ) || settings.offset; 102 103 $.each(settings.axis.split(''), function(i, axis) { 99 104 var Pos = axis === 'x' ? 'Left' : 'Top', 100 105 pos = Pos.toLowerCase(), 101 106 key = 'scroll' + Pos, 102 107 prev = $elem[key](), 103 max = $scrollTo.max( elem, axis);108 max = $scrollTo.max(elem, axis); 104 109 105 110 if (toff) {// jQuery / DOMElement … … 108 113 // If it's a dom element, reduce the margin 109 114 if (settings.margin) { 110 attr[key] -= parseInt( targ.css( 'margin' + Pos ), 10) || 0;111 attr[key] -= parseInt( targ.css( 'border' + Pos + 'Width' ), 10) || 0;115 attr[key] -= parseInt(targ.css('margin'+Pos), 10) || 0; 116 attr[key] -= parseInt(targ.css('border'+Pos+'Width'), 10) || 0; 112 117 } 113 118 … … 121 126 var val = targ[pos]; 122 127 // Handle percentage values 123 attr[key] = val.slice && val.slice( -1) === '%' ?124 parseFloat( val) / 100 * max128 attr[key] = val.slice && val.slice(-1) === '%' ? 129 parseFloat(val) / 100 * max 125 130 : val; 126 131 } 127 132 128 133 // Number or 'number' 129 if (settings.limit && /^\d+$/.test( attr[key])) {134 if (settings.limit && /^\d+$/.test(attr[key])) { 130 135 // Check the limits 131 attr[key] = attr[key] <= 0 ? 0 : Math.min( attr[key], max);136 attr[key] = attr[key] <= 0 ? 0 : Math.min(attr[key], max); 132 137 } 133 138 134 139 // Don't waste time animating, if there's no need. 135 if ( !i && settings.axis.length > 1) {140 if (!i && settings.axis.length > 1) { 136 141 if (prev === attr[key]) { 137 142 // No animation needed … … 139 144 } else if (queue) { 140 145 // Intermediate animation 141 animate( settings.onAfterFirst);146 animate(settings.onAfterFirst); 142 147 // Don't animate this axis again in the next iteration. 143 148 attr = {}; … … 146 151 }); 147 152 148 animate( settings.onAfter);153 animate(settings.onAfter); 149 154 150 155 function animate(callback) { … … 155 160 duration: duration, 156 161 complete: callback && function() { 157 callback.call( elem, targ, settings);162 callback.call(elem, targ, settings); 158 163 } 159 164 }); 160 $elem.animate( attr, opts);165 $elem.animate(attr, opts); 161 166 } 162 167 }); … … 167 172 $scrollTo.max = function(elem, axis) { 168 173 var Dim = axis === 'x' ? 'Width' : 'Height', 169 scroll = 'scroll' +Dim;170 171 if ( ! isWin( elem )) {172 return elem[scroll] - $( elem )[Dim.toLowerCase()](); }174 scroll = 'scroll'+Dim; 175 176 if (!isWin(elem)) 177 return elem[scroll] - $(elem)[Dim.toLowerCase()](); 173 178 174 179 var size = 'client' + Dim, … … 177 182 body = doc.body; 178 183 179 return Math.max( html[scroll], body[scroll] ) - Math.min( html[size], body[size]);184 return Math.max(html[scroll], body[scroll]) - Math.min(html[size], body[size]); 180 185 }; 181 186 182 187 function both(val) { 183 return $.isFunction( val ) || $.isPlainObject( val) ? val : { top:val, left:val };188 return isFunction(val) || $.isPlainObject(val) ? val : { top:val, left:val }; 184 189 } 185 190 186 191 // Add special hooks so that window scroll properties can be animated 187 $.Tween.propHooks.scrollLeft = $.Tween.propHooks.scrollTop = { 192 $.Tween.propHooks.scrollLeft = 193 $.Tween.propHooks.scrollTop = { 188 194 get: function(t) { 189 return $( t.elem)[t.prop]();195 return $(t.elem)[t.prop](); 190 196 }, 191 197 set: function(t) { 192 var curr = this.get( t);198 var curr = this.get(t); 193 199 // If interrupt is true and user scrolled, stop animating 194 200 if (t.options.interrupt && t._last && t._last !== curr) { 195 return $( t.elem).stop();196 } 197 var next = Math.round( t.now);201 return $(t.elem).stop(); 202 } 203 var next = Math.round(t.now); 198 204 // Don't waste CPU 199 205 // Browsers don't render floating point scroll 200 206 if (curr !== next) { 201 $( t.elem)[t.prop](next);202 t._last = this.get( t);207 $(t.elem)[t.prop](next); 208 t._last = this.get(t); 203 209 } 204 210 } -
trunk/src/wp-content/themes/twentyseventeen/functions.php
r53418 r54374 499 499 wp_enqueue_script( 'twentyseventeen-global', get_theme_file_uri( '/assets/js/global.js' ), array( 'jquery' ), '20190121', true ); 500 500 501 wp_enqueue_script( 'jquery-scrollto', get_theme_file_uri( '/assets/js/jquery.scrollTo.js' ), array( 'jquery' ), '2.1. 2', true );501 wp_enqueue_script( 'jquery-scrollto', get_theme_file_uri( '/assets/js/jquery.scrollTo.js' ), array( 'jquery' ), '2.1.3', true ); 502 502 503 503 wp_localize_script( 'twentyseventeen-skip-link-focus-fix', 'twentyseventeenScreenReaderText', $twentyseventeen_l10n );
Note: See TracChangeset
for help on using the changeset viewer.