move() element on window.resize() function not wor

2019-08-22 04:40发布

问题:

This is the move() function

function move(){
/*calculate*/
       var size   = { x: $(window).width(),      y: $(window).height() };
        var scroll = { x: $(window).scrollLeft(), y: $(window).scrollTop() };
        var height = h!=null ? h : this.esqueleto.lightbox.outerHeight();
        var width  = w!=null ? w : this.esqueleto.lightbox.outerWidth();
        var y      = 0;
        var x      = 0;

         //vertically center
        x = scroll.x + ((size.x - width) / 2);

        if (this.visible) {
          y = scroll.y + (size.y - height) / 2;
        } else if (this.options.emergefrom == "bottom") {
          y = (scroll.y + size.y + 14);
        } else {// top
          y = (scroll.y - height) - 14;
        }
/*Process*/
 if (!this.animations.move) {
            this.morph(this.esqueleto.move, {
              'left' : x
            }, 'move');
          }

          this.morph(this.esqueleto.move, {
            'top'  : y
          }, 'move');

        } else {

          this.esqueleto.move.css({
            'left' : x,
            'top'  : y
          });
        }

}

Any idea why is this working in desktop (all browsers), iphone, .. but not in Android?

回答1:

I'm pretty certain scrollLeft doesn't work on android for some reason. Works beautifully on iOS, but I could never get it to work on android. Give it a test and see if you are actually getting a value back for it.

Edit: not just the function scrollLeft(), but really anything to do with horizontal scrolling doesn't seem to work in android.

A workaround I'm using to get things to actually move left/right is are the css properties:

-webkit-transform -webkit-transition-property -webkit-transition-timing-function -webkit-transition-duration

However that might not work for you since you're really just trying to get the value rather than actually move something.