Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Twitter Sign In with OpenID Sign In with Google

Sign In Sign Up

In this Discussion

Tagged

Welcome to the Jo support forums! Please Sign Up and join in the discussion. You can also Sign In instantly with Twitter, OpenID or your Google ID.
State of joScroller
  • maynardsmithmaynardsmith July 2012
    Posts: 4

    Hello,

    I am looking to do exactly what the joScroller code in the second DEMO looks as if it is trying to do (i.e. horizontally scroll a section in the middle of a page), except that it is commented out, and does not work properly if I put it back in.  There are two problems:

    1. Every scroll movement snaps back to the beginning, even if there is overflow on both sides.

    2. It is rendered overlapping the next item on the page. 

    The second looks like a CSS problem, and I guess the first could be as well, but I am not up to diagnosing it.  I am testing on Chrome browser direct, or in combination with PhoneGap (cordova 1.8.1) on an Android emulator, or real device (Andriod 2.3).  I am using jo v0.4.1 with jo2.css.

    Can you tell me if this should work, and if so point me to some sample code?

    With thanks, Tony

     

     

  • maynardsmithmaynardsmith July 2012
    Posts: 4

    Apologies - I have been trying to do too many things at once.

    The above comments apply to running joScroller in Chrome browser.  My target is PhoneGap and Android etc. and I have slapped some jo into an existing test app, but not got the combination going yet.  That's a different problem.

    Regards, Tony

  • maynardsmithmaynardsmith July 2012
    Posts: 4

    OK, I am beginning to get the hang of this.  I have found the following 3 items:

    1.  The positioning of the joScroller needs to be relative, e.g.

    .iconz {
     ...
    position: relative;
    }

    2. The joFlexrow (or other movable item) needs to be wide enough to hold all of its contents without itself overflowing.  e.g.

    .iconz joflexrow {
     ...
    width: 1900px;
    }

    3. Though not relevant to the original problem, there is a typo on line 3763 of jo.js which should read:

    else if (dx < maxx - this.bump)         (not dy).

     

    Regards, Tony

     

  • maynardsmithmaynardsmith July 2012
    Posts: 4

    And once more, and lastly (I hope):

    1.  "width:auto;"   would obviously be better in my last post.

    2.  I have built the attached joSnapScroller which snaps to one of the contained elements (assuming they are all the same width/height).  NB It uses jQuery at one point, which I can't find a quick way round, and doesn't bother me.

    Regards, Tony

    /**
    joSnapScroller
    =========

    As joScroller, but snaps to the boundaries of second level contained objects.
    Assumes that the scrolled object contains a set of equal height/width objects to snap to.

    Use
    ---

    As joScroller.


    Extends
    -------

    - joScroller

    */
    joSnapScroller = function(data) {
    joScroller.apply(this, arguments);
    };
    joSnapScroller.extend(joScroller, {
    tagName: "joscroller", // Don't see a need to distinguish

    // Alternative version with "snap to content" feature
    // Assumes all contents are same height/width (as required)
    snapBack: function() {
    var node = this.container.firstChild;
    var top = this.getTop();
    var left = this.getLeft();

    var celly = $(node.firstChild).outerHeight(true);
    var cellx = $(node.firstChild).outerWidth(true);

    var dy = Math.round(top/celly) * celly;
    var dx = Math.round(left/cellx) * cellx;

    var max = 0 - node.offsetHeight + this.container.offsetHeight;
    var maxx = 0 - node.offsetWidth + this.container.offsetWidth;

    if (this.eventset)
    joEvent.remove(node, this.transitionEnd, this.eventset);

    this.eventset = null;

    joDOM.removeCSSClass(node, 'flick');

    if (dy > 0)
    dy = 0;
    else if (dy < max)
    dy = max;

    if (dx > 0)
    dx = 0;
    else if (dx < maxx)
    dx = maxx;

    if (dx != left || dy != top) {
    joDOM.addCSSClass(node, 'flickback');
    this.moveTo(dx, dy);
    }
    }


    });