Toggle button is broken in the Chrome version 41.0.2272.118 m
ilyassa opened this issue · comments
Chrome version 41.0.2272.118 m
window.getComputedStyle returns rational numbers (not rounding numbers). For this reason toggle button doesn't close a menu from the left side. I didn't check the right side menu.
When we call the public methd state, fromLeft property gets incorrect result from the action.translate.get.matrix(4)
this.state = function() {
var state,
fromLeft = action.translate.get.matrix(4);
if (fromLeft === settings.maxPosition) {
state = 'left';
} else if (fromLeft === settings.minPosition) {
state = 'right';
} else {
state = 'closed';
}
return {
state: state,
info: cache.simpleStates
};
};
Temporary workaround:
matrix: function(index) {
if( !utils.canTransform() ){
return parseInt(settings.element.style.left, 10);
} else {
var matrix = win.getComputedStyle(settings.element)[cache.vendor+'Transform'].match(/\((.*)\)/),
ieOffset = 8;
if (matrix) {
matrix = matrix[1].split(',');
if(matrix.length===16){
index+=ieOffset;
}
// todo: round matrix instead of parsing
//return parseInt(matrix[index], 10);
return Math.round(matrix[index]);
}
return 0;
}
}
me too!
var matrixValue = parseFloat(matrix[index]);
return matrixValue < 0 ? Math.floor(matrix[index]) : parseInt(matrix[index], 10);
u something better!
in next link the toogle button works fine...
/* Get reference to toggle button, the html element with ID "open-left" */
var myToggleButton = document.getElementById('open-left')
/* Add event listener to our toggle button */
myToggleButton.addEventListener('click', function() {
if (snapper.state().state == "left") {
snapper.close();
} else {
snapper.open('left');
}
});