mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
Fixed #99 with requestAnimationFrame polyfill
This commit is contained in:
16
js/utils/poly.js
Normal file
16
js/utils/poly.js
Normal file
@@ -0,0 +1,16 @@
|
||||
(function(ionic) {
|
||||
'use strict';
|
||||
|
||||
// From the man himself, Mr. Paul Irish.
|
||||
// The requestAnimationFrame polyfill
|
||||
window.rAF = (function(){
|
||||
return window.requestAnimationFrame ||
|
||||
window.webkitRequestAnimationFrame ||
|
||||
window.mozRequestAnimationFrame ||
|
||||
function( callback ){
|
||||
window.setTimeout(callback, 1000 / 60);
|
||||
};
|
||||
})();
|
||||
|
||||
|
||||
})(window.ionic);
|
||||
@@ -65,7 +65,7 @@
|
||||
SlideDrag.prototype.drag = function(e) {
|
||||
var _this = this, buttonsWidth;
|
||||
|
||||
window.requestAnimationFrame(function() {
|
||||
window.rAF(function() {
|
||||
// We really aren't dragging
|
||||
if(!_this._currentDrag) {
|
||||
return;
|
||||
@@ -132,7 +132,7 @@
|
||||
e.target.removeEventListener('webkitTransitionEnd', onRestingAnimationEnd);
|
||||
};
|
||||
|
||||
window.requestAnimationFrame(function() {
|
||||
window.rAF(function() {
|
||||
var currentX = parseFloat(_this._currentDrag.content.style.webkitTransform.replace('translate3d(', '').split(',')[0]) || 0;
|
||||
if(currentX !== restingPoint) {
|
||||
_this._currentDrag.content.classList.add(ITEM_SLIDING_CLASS);
|
||||
@@ -181,7 +181,7 @@
|
||||
ReorderDrag.prototype.drag = function(e) {
|
||||
var _this = this;
|
||||
|
||||
window.requestAnimationFrame(function() {
|
||||
window.rAF(function() {
|
||||
// We really aren't dragging
|
||||
if(!_this._currentDrag) {
|
||||
return;
|
||||
|
||||
@@ -21,18 +21,16 @@
|
||||
var _this = this;
|
||||
|
||||
if(this._loadingBox) {
|
||||
//window.requestAnimationFrame(function() {
|
||||
var lb = _this._loadingBox;
|
||||
var lb = _this._loadingBox;
|
||||
|
||||
var width = Math.min(_this.maxWidth, Math.max(window.outerWidth - 40, lb.offsetWidth));
|
||||
var width = Math.min(_this.maxWidth, Math.max(window.outerWidth - 40, lb.offsetWidth));
|
||||
|
||||
lb.style.width = width;
|
||||
lb.style.width = width;
|
||||
|
||||
lb.style.marginLeft = (-lb.offsetWidth) / 2 + 'px';
|
||||
lb.style.marginTop = (-lb.offsetHeight) / 2 + 'px';
|
||||
lb.style.marginLeft = (-lb.offsetWidth) / 2 + 'px';
|
||||
lb.style.marginTop = (-lb.offsetHeight) / 2 + 'px';
|
||||
|
||||
_this.el.classList.add('active');
|
||||
//});
|
||||
_this.el.classList.add('active');
|
||||
}
|
||||
},
|
||||
hide: function() {
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
alert: function(message) {
|
||||
var _this = this;
|
||||
|
||||
window.requestAnimationFrame(function() {
|
||||
window.rAF(function() {
|
||||
_this.setTitle(message);
|
||||
_this.el.classList.add('active');
|
||||
});
|
||||
|
||||
@@ -430,7 +430,7 @@
|
||||
|
||||
this.el.style.webkitTransitionDuration = '0';
|
||||
|
||||
window.requestAnimationFrame(function() {
|
||||
window.rAF(function() {
|
||||
if(_this.wrapScrollPosition(_this.bounceTime)) {
|
||||
_this._didEndScroll = true;
|
||||
}
|
||||
@@ -545,7 +545,7 @@
|
||||
var drag = _this._drag;
|
||||
|
||||
// Request an animation frame to batch DOM reads/writes
|
||||
window.requestAnimationFrame(function() {
|
||||
window.rAF(function() {
|
||||
// We are dragging, grab the current content height
|
||||
|
||||
var totalWidth = _this.el.scrollWidth;
|
||||
@@ -650,7 +650,7 @@
|
||||
// animate to that position
|
||||
_animateToStop: function(e) {
|
||||
var _this = this;
|
||||
window.requestAnimationFrame(function() {
|
||||
window.rAF(function() {
|
||||
|
||||
var drag = _this._drag;
|
||||
|
||||
|
||||
@@ -192,7 +192,7 @@
|
||||
var _this = this,
|
||||
finalOffsetX, content, ratio, slideWidth, totalWidth, offsetX;
|
||||
|
||||
window.requestAnimationFrame(function() {
|
||||
window.rAF(function() {
|
||||
|
||||
// We didn't have a drag, so just init and leave
|
||||
if(!_this._drag) {
|
||||
@@ -285,7 +285,7 @@
|
||||
_handleDrag: function(e) {
|
||||
var _this = this;
|
||||
|
||||
window.requestAnimationFrame(function() {
|
||||
window.rAF(function() {
|
||||
var content;
|
||||
|
||||
// We really aren't dragging
|
||||
|
||||
Reference in New Issue
Block a user