Skip to content

Toggle button is broken in the Chrome version 41.0.2272.118 m #256

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

Open
ilyassa opened this issue Apr 3, 2015 · 2 comments
Open

Toggle button is broken in the Chrome version 41.0.2272.118 m #256

ilyassa opened this issue Apr 3, 2015 · 2 comments

Comments

@ilyassa
Copy link

ilyassa commented Apr 3, 2015

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;
                        }
                    }
@syredeye
Copy link

syredeye commented Apr 8, 2015

me too!
var matrixValue = parseFloat(matrix[index]);
return matrixValue < 0 ? Math.floor(matrix[index]) : parseInt(matrix[index], 10);
u something better!

@mialmoga
Copy link

mialmoga commented May 4, 2015

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');
            }

        });

http://runnable.com/Uoqf6mc0AHx3AAAh/how-to-create-a-toggle-button-for-a-snap-js-mobile-shelf-for-javascript

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants