1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

add transition to remote control

This commit is contained in:
Luke Pulverenti 2015-03-18 00:09:31 -04:00
parent c5b0fd9b79
commit b73c66bd7f
8 changed files with 142 additions and 70 deletions

View file

@ -508,59 +508,6 @@ function ticks_to_human(str) {
return time;
};
/******************************************************************************/
/*********************************** EASING ***********************************/
/******************************************************************************/
(function () {
// based on easing equations from Robert Penner (http://www.robertpenner.com/easing)
var baseEasings = {};
$.each(["Quad", "Cubic", "Quart", "Quint", "Expo"], function (i, name) {
baseEasings[name] = function (p) {
return Math.pow(p, i + 2);
};
});
$.extend(baseEasings, {
Sine: function (p) {
return 1 - Math.cos(p * Math.PI / 2);
},
Circ: function (p) {
return 1 - Math.sqrt(1 - p * p);
},
Elastic: function (p) {
return p === 0 || p === 1 ? p :
-Math.pow(2, 8 * (p - 1)) * Math.sin(((p - 1) * 80 - 7.5) * Math.PI / 15);
},
Back: function (p) {
return p * p * (3 * p - 2);
},
Bounce: function (p) {
var pow2,
bounce = 4;
while (p < ((pow2 = Math.pow(2, --bounce)) - 1) / 11) { }
return 1 / Math.pow(4, 3 - bounce) - 7.5625 * Math.pow((pow2 * 3 - 2) / 22 - p, 2);
}
});
$.each(baseEasings, function (name, easeIn) {
$.easing["easeIn" + name] = easeIn;
$.easing["easeOut" + name] = function (p) {
return 1 - easeIn(1 - p);
};
$.easing["easeInOut" + name] = function (p) {
return p < 0.5 ?
easeIn(p * 2) / 2 :
1 - easeIn(p * -2 + 2) / 2;
};
});
})();
(function (window) {
// Mimic Globalize api
@ -582,4 +529,73 @@ function ticks_to_human(str) {
}
};
})(window);
})(window);
(function () {
var supportTouch = $.support.touch,
scrollEvent = "touchmove scroll",
touchStartEvent = supportTouch ? "touchstart" : "mousedown",
touchStopEvent = supportTouch ? "touchend" : "mouseup",
touchMoveEvent = supportTouch ? "touchmove" : "mousemove";
$.event.special.swipeupdown = {
setup: function () {
var thisObject = this;
var $this = $(thisObject);
$this.bind(touchStartEvent, function (event) {
var data = event.originalEvent.touches ?
event.originalEvent.touches[0] :
event,
start = {
time: (new Date).getTime(),
coords: [data.pageX, data.pageY],
origin: $(event.target)
},
stop;
function moveHandler(event) {
if (!start) {
return;
}
var data = event.originalEvent.touches ?
event.originalEvent.touches[0] :
event;
stop = {
time: (new Date).getTime(),
coords: [data.pageX, data.pageY]
};
// prevent scrolling
if (Math.abs(start.coords[1] - stop.coords[1]) > 10) {
event.preventDefault();
}
}
$this
.bind(touchMoveEvent, moveHandler)
.one(touchStopEvent, function (event) {
$this.unbind(touchMoveEvent, moveHandler);
if (start && stop) {
if (stop.time - start.time < 1000 &&
Math.abs(start.coords[1] - stop.coords[1]) > 30 &&
Math.abs(start.coords[0] - stop.coords[0]) < 75) {
start.origin
.trigger("swipeupdown")
.trigger(start.coords[1] > stop.coords[1] ? "swipeup" : "swipedown");
}
}
start = stop = undefined;
});
});
}
};
$.each({
swipedown: "swipeupdown",
swipeup: "swipeupdown"
}, function (event, sourceEvent) {
$.event.special[event] = {
setup: function () {
$(this).bind(sourceEvent, $.noop);
}
};
});
})();