+++ /dev/null
-!function($, Foundation, window){
- var Move = function(duration, elem, fn){
- var anim, prog, start = null, _this = this;
- this.dont = function(){
- if(anim !== undefined){
- window.cancelAnimationFrame(anim);
- duration = 0;
- return true;
- }
- return false;
- };
- this.do = function(ts){//timestamp returned from requestAnimationFrame
- if(!ts || !start){ start = ts = window.performance.now(); }
- prog = ts - start;
- // console.log(prog, ts, start);
- fn.apply(elem);//call the cb
- if(prog < duration){
- anim = window.requestAnimationFrame(_this.do, elem);
- }else{
- window.cancelAnimationFrame(anim);
- elem.trigger('finished.zf.animate', [elem]);
- }
- };
- window.requestAnimationFrame(this.do);
- };
- Foundation.Move = Move;
-}(jQuery, window.Foundation, window);
/**
* Motion module.
* @module foundation.motion
- * @requires foundation.util.animationFrame
*/
!function($, Foundation) {
// });
// Clean up the animation when it finishes
- element.one(Foundation.transitionend, finish).one('finished.zf.animate', finish);
+ element.one(Foundation.transitionend, finish);//.one('finished.zf.animate', finish);
// Hides the element (for out animations), resets the element, and runs a callback
function finish() {
+++ /dev/null
-!function($, Foundation){
- 'use strict';
- /**
- * Runs a callback function when images are fully loaded.
- * @param {Object} images - Image(s) to check if loaded.
- * @param {Func} callback - Function to execute when image is fully loaded.
- */
- var onImagesLoaded = function(images, callback){
- var self = this,
- unloaded = images.length;
-
- if (unloaded === 0) {
- callback();
- }
-
- var singleImageLoaded = function() {
- unloaded--;
- if (unloaded === 0) {
- callback();
- }
- };
-
- images.each(function() {
- if (this.complete) {
- singleImageLoaded();
- }
- else if (typeof this.naturalWidth !== 'undefined' && this.naturalWidth > 0) {
- singleImageLoaded();
- }
- else {
- $(this).one('load', function() {
- singleImageLoaded();
- });
- }
- });
- };
- Foundation.onImagesLoaded = onImagesLoaded;
-}(jQuery, window.Foundation);
var dir;
elapsedTime = new Date().getTime() - startTime;
if(Math.abs(dx) >= $.spotSwipe.moveThreshold && elapsedTime <= $.spotSwipe.timeThreshold) {
- dir = dx > 0 ? 'left' : 'right'
+ dir = dx > 0 ? 'left' : 'right';
}
else if(Math.abs(dy) >= $.spotSwipe.moveThreshold && elapsedTime <= $.spotSwipe.timeThreshold) {
- dir = dy > 0 ? 'down' : 'up'
+ dir = dy > 0 ? 'down' : 'up';
}
if(dir) {
onTouchEnd.call(this);
startPosX = e.touches[0].pageX;
startPosY = e.touches[0].pageY;
isMoving = true;
- startTime = new Date().getTime()
+ startTime = new Date().getTime();
this.addEventListener('touchmove', onTouchMove, false);
this.addEventListener('touchend', onTouchEnd, false);
}
+++ /dev/null
-!function($, Foundation){
-
- /******************************************************************
- /** A very simple timer for animated elements within Foundation. **
- /** Allows your script to pause and restart later with fn call. **
- /** Feel free to add features, comments, or use case examples. **
- /*****************************************************************/
-
- var Timer = function(elem, options, cb){
- var _this = this,
- duration = options.duration,//options is an object for easily adding features later.
- nameSpace = Object.keys(elem.data())[0] || 'timer',
- remain = -1,
- start,
- timer;
-
- this.restart = function(){
- remain = -1;
- clearTimeout(timer);
- this.start();
- };
-
- this.start = function(){
- // if(!elem.data('paused')){ return false; }//maybe implement this sanity check if used for other things.
- clearTimeout(timer);
- remain = remain <= 0 ? duration : remain;
- elem.data('paused', false);
- start = Date.now();
- timer = setTimeout(function(){
- if(options.infinite){
- _this.restart();//rerun the timer.
- }
- cb();
- }, remain);
- elem.trigger('timerstart.zf.' + nameSpace);
- };
-
- this.pause = function(){
- //if(elem.data('paused')){ return false; }//maybe implement this sanity check if used for other things.
- clearTimeout(timer);
- elem.data('paused', true);
- var end = Date.now();
- remain = remain - (end - start);
- elem.trigger('timerpaused.zf.' + nameSpace);
- };
- };
-
- Foundation.Timer = Timer;
-
-}(jQuery, window.Foundation);