Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firefox support for swipe #35

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 29 additions & 7 deletions js/flux.js
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 +488,8 @@ window.flux = {
},
supportsCSSProperty: function(prop) {
var div = document.createElement('div'),
prefixes = ['-webkit', '-moz', '-o', '-ms'],
domPrefixes = ['Webkit', 'Moz', 'O', 'Ms'];
prefixes = ['', '-webkit', '-moz', '-o', '-ms'],
domPrefixes = ['', 'Webkit', 'Moz', 'O', 'Ms'];

var support = false;
for(var i=0; i<domPrefixes.length; i++)
Expand Down Expand Up @@ -1507,6 +1507,18 @@ window.flux = {
flux.transitions.swipe = function(fluxslider, opts) {
return new flux.transition(fluxslider, $.extend({
setup: function() {
var svgmask = $('<svg id="svgmask" xmlns="http://www.w3.org/2000/svg" height="0px">' +
'<linearGradient id="myGradient" gradientTransform="translate(0,0)">' +
'<animateTransform attributeName="gradientTransform"' +
'dur="1600ms" type="translate" from="-0.1 0" to="1.1 0" fill="freeze"/>' +
'<stop offset="0%" stop-color="white" stop-opacity="0"/>' +
'<stop offset="10%" stop-color="white"/>' +
'<stop offset="0%" stop-color="white"/>' +
'</linearGradient>' +
'<mask id="myMask" maskUnits="objectBoundingBox" maskContentUnits="objectBoundingBox">' +
'<rect fill="url(#myGradient)" x="0" y="0" width="1" height="1"/>' +
'</mask>' +
'</svg>');
var img = $('<div></div>').css({
width: '100%',
height: '100%',
Expand All @@ -1521,6 +1533,7 @@ window.flux = {
});

this.slider.image1.append(img);
this.slider.image1.append(svgmask);
},
execute: function() {
//return;
Expand All @@ -1530,16 +1543,25 @@ window.flux = {
// Get notified when the last transition has completed
$(img).transitionEnd(function(){
_this.finished();
});
}).get()[0].addEventListener('end', function() {
_this.finished();
}, false);

setTimeout(function(){
$(img).css3({
'mask-position': '30%'
});
if (flux.browser.supportsCSSProperty('MaskImage')) {
$(img).css3({
'mask-position': '30%'
});
} else if (flux.browser.supportsCSSProperty('mask')) {
$(img).css3({
'mask': 'url(#myMask)'
});
}
}, 50);
},
compatibilityCheck: function() {
return flux.browser.supportsCSSProperty('MaskImage');
return flux.browser.supportsCSSProperty('MaskImage') ||
flux.browser.supportsCSSProperty('mask');
}
}, opts));
};
Expand Down
11 changes: 6 additions & 5 deletions js/flux.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions js/src/flux.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
},
supportsCSSProperty: function(prop) {
var div = document.createElement('div'),
prefixes = ['-webkit', '-moz', '-o', '-ms'],
domPrefixes = ['Webkit', 'Moz', 'O', 'Ms'];
prefixes = ['', '-webkit', '-moz', '-o', '-ms'],
domPrefixes = ['', 'Webkit', 'Moz', 'O', 'Ms'];

var support = false;
for(var i=0; i<domPrefixes.length; i++)
Expand Down
32 changes: 27 additions & 5 deletions js/src/flux.transitions.swipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@
flux.transitions.swipe = function(fluxslider, opts) {
return new flux.transition(fluxslider, $.extend({
setup: function() {
var svgmask = $('<svg id="svgmask" xmlns="http://www.w3.org/2000/svg" height="0px">' +
'<linearGradient id="myGradient" gradientTransform="translate(0,0)">' +
'<animateTransform attributeName="gradientTransform"' +
'dur="1600ms" type="translate" from="-0.1 0" to="1.1 0" fill="freeze"/>' +
'<stop offset="0%" stop-color="white" stop-opacity="0"/>' +
'<stop offset="10%" stop-color="white"/>' +
'<stop offset="0%" stop-color="white"/>' +
'</linearGradient>' +
'<mask id="myMask" maskUnits="objectBoundingBox" maskContentUnits="objectBoundingBox">' +
'<rect fill="url(#myGradient)" x="0" y="0" width="1" height="1"/>' +
'</mask>' +
'</svg>');
var img = $('<div></div>').css({
width: '100%',
height: '100%',
Expand All @@ -16,6 +28,7 @@
});

this.slider.image1.append(img);
this.slider.image1.append(svgmask);
},
execute: function() {
//return;
Expand All @@ -25,16 +38,25 @@
// Get notified when the last transition has completed
$(img).transitionEnd(function(){
_this.finished();
});
}).get()[0].addEventListener('end', function() {
_this.finished();
}, false);

setTimeout(function(){
$(img).css3({
'mask-position': '30%'
});
if (flux.browser.supportsCSSProperty('MaskImage')) {
$(img).css3({
'mask-position': '30%'
});
} else if (flux.browser.supportsCSSProperty('mask')) {
$(img).css3({
'mask': 'url(#myMask)'
});
}
}, 50);
},
compatibilityCheck: function() {
return flux.browser.supportsCSSProperty('MaskImage');
return flux.browser.supportsCSSProperty('MaskImage') ||
flux.browser.supportsCSSProperty('mask');
}
}, opts));
};
Expand Down