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

Fix issue #517: Menusheet (Menu Sheet) broken in Chrome #529

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 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
3 changes: 1 addition & 2 deletions extensions/jqt.menusheet.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#jqt > div.menusheet {
-webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box;
height: 100%;
width: 260px;
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@illucent, it should not be removed. The menu is not designed to be fully opened.

Please remove the changes to css.

#jqt.black-translucent > div.menusheet {
padding-top: 20px;
Expand All @@ -21,7 +20,7 @@
}

#jqt.menuopened > .current {
-webkit-transform: translate3d(260px, 0, 0) rotate(0) scale(1);
-webkit-transform: translate3d(0, 0, 0) rotate(0) scale(1);
-webkit-box-shadow: -3px 0px 3px rgba(63, 63, 63, 0.5);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@illucent, please revert this change, and do git rebase.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reverted and removed -webkit-* prefix to make it more compatible
css transform: translate3d(260px, 0, 0) rotate(0) scale(1);

border-left: 0.5px solid rgba(127, 127, 127, 0.01);
z-index: 20;
Expand Down
96 changes: 75 additions & 21 deletions extensions/jqt.menusheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,74 @@
jQTouch may be freely distributed under the MIT license.
*/


var transition = {

// Determines proper transition property per browser
whichTransitionEvent: function(){

var el = document.createElement('menuelement');

var transitions = {
'WebkitTransition':'webkitTransitionEnd', // Saf 6, Android Browser
'OTransition':'oTransitionEnd otransitionend',
'MozTransition':'transitionend', // only for FF < 15
'transition':'transitionend' // IE10, Opera, Chrome, FF 15+, Saf 7+
};

for(t in transitions){
if( el.style[t] !== undefined ){
return transitions[t];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@illucent Just do:

$source.one(TRANSITION_NAMES, function() {

}
}

return false;
}

};

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While it is fine. I just rather have them lump together. Please remove the block.

(function($) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just add a line:

var TRANSITION_NAMES = 'webkitTransitionEnd msTransitionEnd transitionend'; 

I really don't think Opera matter.

var src = $("head script").last().attr("src") || '';
var scriptpath = src.split('?')[0].split('/').slice(0, -1).join('/')+'/';
var csspath = scriptpath + 'jqt.menusheet.css';
var link = $('<link href="' + csspath + '" rel="stylesheet">');

$('head').append($(link));

function hide(callback) {
var $target = $(this);
var data = $(this).data('menusheet');

if (data.shown) {
$(this).data('menusheet', {});
var $source = data.source;
var transitionEnd = transition.whichTransitionEvent();

$target.trigger('pageAnimationStart', {
direction: 'out', animation: undefined, back: true
});

var watchdogTimer;

$source.unbind('touchstart mousedown', data.closehandler);
$source.one('webkitTransitionEnd', function() {
$source.removeClass('inmotion transition in');
$target.removeClass('inmotion out');
$target.trigger('pageAnimationEnd', {
direction: 'out', animation: undefined, back: true
});
!callback || callback.apply(this, arguments);
$source.on(transitionEnd , function menu(event) {
if (event.target === this) {
$(this).off(transitionEnd, menu);
clearTimeout(watchdogTimer);
$source.removeClass('inmotion transition in');
$target.removeClass('inmotion out');
$target.trigger('pageAnimationEnd', {
direction: 'out', animation: undefined, back: true
});
!callback || callback.apply(this, arguments);
}
});

$source.addClass('inmotion transition in');

watchdogTimer = setTimeout(function() {
$source.trigger(transitionEnd);
}, 750);

$source.addClass('inmotion transition in');
$target.addClass('inmotion out').removeClass('current');
$('#jqt').removeClass('menuopened');
}
Expand All @@ -55,6 +96,9 @@
function show(callback) {
var $target = $(this);
var data = $(this).data('menusheet') || {};
var watchdogTimer;
var transitionEnd = transition.whichTransitionEvent();

if (!data.shown) {
var $source = $('#jqt .current:not(.menusheet)');
$target.trigger('pageAnimationStart', {
Expand All @@ -65,22 +109,32 @@
return false;
};

$source.one('webkitTransitionEnd', function() {
$source.one('touchstart mousedown', closehandler);
$source.removeClass('inmotion transition out');
$target.removeClass('inmotion in');
$target.trigger('pageAnimationEnd', {
direction: 'in', animation: undefined, back: false
});
!callback || callback.apply(this, arguments);
$source.on(transitionEnd , function menu(event) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@illucent, same as above.

if (event.target === this) {
$(this).off(transitionEnd, menu);
clearTimeout(watchdogTimer);
$source.one('touchstart mousedown', closehandler);
$source.removeClass('inmotion transition out');

$target.removeClass('inmotion in');
$target.trigger('pageAnimationEnd', {
direction: 'in', animation: undefined, back: false
});
!callback || callback.apply(this, arguments);
}
});


watchdogTimer = setTimeout(function() {
$source.trigger(transitionEnd);
}, 750);

data.shown = true;
data.closehandler = closehandler;
data.source = $source;
$(this).data('menusheet', data);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not add extra space.

$source.addClass('inmotion transition out');

$target.addClass('current in');
$('#jqt').addClass('menuopened');
}
Expand Down Expand Up @@ -119,7 +173,7 @@
},
fn: function(e, params) {
params.$el.removeClass('active');

var $target = $(params.hash);
$target.menusheet('show');

Expand Down Expand Up @@ -149,4 +203,4 @@
} else {
console.error('Extension `jqt.menusheet` failed to load. jQT not found');
}
})($);
}( jQuery || $ )); // jQuery or jQuery-like library, such as Zepto
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@illucent, do we really need to change it? I think we have test that passing on both.