Giter Club home page Giter Club logo

ftscroller's Introduction

FTScroller

FTScroller is a library for adding momentum scrolling to web content on devices with a touch interface, compatible across most modern platforms including desktop browsers. Although recently support for overflow: scroll (or touch equivalents) has increased, this is often still not implemented in a cross-platform or backwards-compatible way, and with no support for features like snapping.

FTScroller is developed by FT Labs, part of the Financial Times. It is inspired by Touchscroll and Zynga Scroller, but is a complete rewrite. It is extensively used in the FT Web App, and was developed to achieve better performance and compatibility, including mouse and touch input.

Usage

Include ftscroller.js in your JavaScript bundle or add it to your HTML page like this:

<script type='text/javascript' src='/path/to/ftscroller.js'></script>

The script must be loaded prior to instantiating a scroller on any element of the page.

To create a scroller, with a few minimal options:

var containerElement, scroller;

containerElement = document.getElementById('scrollcontainer');

scroller = new FTScroller(containerElement, {
	scrollbars: false,
	scrollingX: false
});

Examples

FTScroller is designed to accommodate a range of use cases. Here are some examples - feel free to copy the code and use as the basis for your own projects.

Options

Options must be specified at create-time by passing a JSON object as the second argument to the FTScroller constructor.

  • alwaysScroll Whether to always enable scrolling, even if the content of the scroller is not large enough to spill out of the container. This makes the scroller behave more like an element set to "overflow: scroll", with bouncing always occurring if enabled (boolean, default false)
  • baseAlignments Determines where to anchor the content when the scroller is set up, specified individually for each axis using a JSON object with the keys x and y. Valid alignments for each axis are -1 (top or left), 0 (center), and 1 (bottom or right). For example, the default baseAlignments of {x:-1,y:-1} will display the scroller initially scrolled to the top left of its range. This also affects the alignment of content where the content is smaller than the scroller.
  • bouncing Allow scroll bouncing and elasticity near the ends of the range and at snap points (boolean, default true)
  • contentWidth Define the scrollable width; if not defined, this will match the content width (numeric, default undefined)
  • contentHeight Define the scrollable height; if not defined, this will match the content height (numeric, default undefined)
  • disabledInputMethods Define any input methods to disable; on some multi-input devices custom behaviour may be desired for some scrollers. No inputs methods are disabled by default. (object, default { mouse: false, touch: false, scroll: false, pointer: false, focus: false })
  • enableRequestAnimationFrameSupport FTScroller will use requestAnimationFrame on platforms which support it, which is highly recommended; however this can result in the animation being a further half-frame behind the input method, increasing perceived lag slightly. To disable this, set this property to false. (boolean, default true)
  • flinging Allow a fast scroll to continue with momentum when released (boolean, default true)
  • hwAccelerationClass FTScroller uses normal translate properties rather than translate3d to position content when scrolling, and triggers hardware acceleration by adding CSS properties (specifically backface-visibility) to this class on platforms that support it. Adjusting this class allows for negotiating complex CSS inheritance to override the default behaviour of FTScroller if you want to change or disable backing layers/3D acceleration. (string, default an internal class which triggers backing layers)
  • maxFlingDuration Set the maximum time (ms) that a fling can take to complete once the input has ended (numeric, default 1000ms)
  • scrollbars Whether to display iOS-style scrollbars (which you can style yourself using .ftscroller_scrollbar and .ftscroller_scrollbarx/.ftscroller_scrollbary) while the content is animating (boolean, default true)
  • scrollBoundary The initial movement required to trigger a full scroll, in pixels; this is the point at which the scroll is exclusive to this particular FTScroller instance and flings become active (integer, default 1)
  • scrollingClassName The classname to add to the scroller container when it is being actively scrolled. This is disabled by default as it can cause a CSS relayout if enabled, but allows custom styling in response to scrolls (string, default not set)
  • scrollResponseBoundary The initial movement required to trigger a visual scroll update, in pixels (integer, default 1)
  • scrollingX Enable scrolling on the X axis if content is available (boolean, default true)
  • scrollingY Enable scrolling on the Y axis if content is available (boolean, default true)
  • singlePageScrolls (was paginatedSnap) If snapping is enabled, restricts each scroll movement to one 'page' span. That is, if set to true, it will not be possible to move more than one page in a single movement. (boolean, default false)
  • snapping Enable snapping of content to defined 'pages' or segments (boolean, default false)
  • snapSizeX Define the horizontal interval content should snap to, in pixels. If this is not set, snapping will be based on pages corresponding to the container size. (numeric, default undefined)
  • snapSizeY Define the vertical interval content should snap to, in pixels. If this is not set, snapping will be based on pages corresponding to the container size. (numeric, default undefined)
  • updateOnChanges Automatically detect changes to the content of the scrollable element and update the scroller dimensions whenever the content changes. This is set to false automatically if contentWidth and contentHeight are specified (boolean, default true)
  • updateOnWindowResize Automatically catch changes to the window size and update the dimensions of the scroller. It's advisable to set this to true if the scroller has a flexible width or height based on the viewport size. (boolean, default false)
  • windowScrollingActiveFlag Whether to use a global property of the window object to control whether to allow scrolling to start or not. If the specified window property is set to a truthy value, the scroller will not react to input. If the property is not truthy, the scroller will set it to itself and will scroll. Where multiple scrollers exist on the same page, this ensures that only one can be used at a time, which is particularly useful for nested scrollers (see Multiple vertical scrollers in a horizontally paged scroller). Note that FTScroller automatically allows only one scroller instance to be scrolled at once; use this flag to coordinate input with other parts of your code. (string, default not set)
  • flingBezier The bezier curve to use for momentum-like flings. (CubicBezier, default CubicBezier(0.103, 0.389, 0.307, 0.966))
  • bounceDecelerationBezier The bezier curve to use for deceleration when a fling hits the bounds. (CubicBezier, default CubicBezier(0, 0.5, 0.5, 1))
  • bounceBezier The bezier curve to use for bouncebacks when the scroll exceeds the bounds. (CubicBezier, default CubicBezier(0.7, 0, 0.9, 0.6))
  • invertScrollWheel If the scroller is constrained to an x axis, convert y scroll to allow single-axis scroll wheels to scroll constrained content. (boolean, default true)

Public interface

Once the scroller has been applied to an element, the return value from the constructor is an object that offers a number of public properties, methods and events.

Properties

  • scrollHeight Gets the scrollable height of the contained content. Read only
  • scrollLeft Gets or sets the current left scroll offset of the scroller in pixels. When set, will cause the scroller to jump to that position (without animating)
  • scrollTop Gets or sets the current top scroll offset of the scroller in pixels. When set, will cause the scroller to jump to that position (without animating)
  • scrollWidth Gets the scrollable width of the contained content. Read only
  • segmentCount When snapping is enabled, returns the number of snap segments (which in many use cases can be considered 'pages'). Read only.
  • currentSegment Returns the index of the current segment, starting from 0. Updated when the scroller comes to rest on a new segment. Applies only when snapping is set to true. Read only.
  • contentContainerNode Returns the DOM node that contains the scroller contents, for use if you want to amend the contents. Read only.

Methods

  • addEventListener(eventname, callback) Attaches a specified function to an FTScroller custom event. Available events are listed in the events section below. The function will be called by FTScroller when the event occurs.
  • destroy(removeElements) Unbinds all event listeners to prevent circular references preventing items from being deallocated, and clean up references to dom elements. Does not remove scroller markup from the DOM unless the optional removeElements argument is set to a truthy value.
  • removeEventListener(eventname, callback) Removes a previously bound function from an event. The function specified in the mathod must be the same object reference passed in the addEventListener call (not a redefinition of the same function code)
  • scrollBy(horizontal, vertical[, duration]) Similar to scrollTo but allows scrolling relative to the current position rather than to an absolute offset.
  • scrollTo(left, top[, duration]) Scroll to a specified left and top offet over a specified duration. If duration is zero, no animation will occur. If duration is true FTScroller will itself choose a duration based on the distance to be scrolled. The left and top inputs will be constrained by the size of the content and the snap points. If false is supplied for either left or top, that axis will not be scrolled and will retain its current offset.
  • setSnapSize(width, height) Configures the snapping boundaries within the scrolling element if snapping is active. If this is never called, segment size defaults to the width and height of the scroller, ie. page-at-a-time.
  • updateDimensions(width, height[, nosnap]) Sets the dimensions of the scrollable content. If snapping is enabled, and you wish to disable updates of the snapping grid and prevent the current position from being updated, set nosnap to true; it defaults to false if not supplied.
  • setDisabledInputMethods(disabledInputMethods) Set the input methods to disable. No inputs methods are disabled by default. (object, default { mouse: false, touch: false, scroll: false, pointer: false, focus: false })

Prototype methods

  • getPrependedHTML([excludeXAxis, excludeYAxis, hwAccelerationClass]) - Provides half of the HTML that is used to construct the scroller DOM, for use to save a DOM manipulation on Scroller initialisation (see Tips and tricks below). Optionally the x and y axes can be excluded, or a custom layer backing triggering class can be supplied (see the hwAccelerationClass option for the constructor).
  • getAppendedHTML([excludeXAxis, excludeYAxis, hwAccelerationClass, scrollbars]) - Provides the second half of the HTML that is used to construct the scroller DOM, for use to save a DOM manipulation on Scroller initialisation (see Tips and tricks below). Optionally the x and y axes can be excluded, or a custom layer backing triggering class can be supplied (see the hwAccelerationClass option for the constructor). Pass a truthy value in for the scrollbars parameter if you are enabling scrolling. Any parameters should match those passed in to getPrependedHTML.

Events

Events can be bound with the addEventListener method. Events are fired syncronously. Regardless of the event, the listener function will receive a single argument.

  • scroll Fired whenever the scroll position changes, continuously if an input type is modifying the position. Passes an object containing scrollLeft and scrollTop properties matching the new scroll position, eg {scrollLeft:10, scrollTop:45}
  • scrollstart Fired when a scroll movement starts. Passes an object with the same characteristics as scroll.
  • scrollend Fired when a scroll movement ends. Passes an object with the same characteristics as scroll.
  • segmentdidchange Fires on completion of a scroll movement, if the scroller is on a different segment to the one it was on at the start of the movement. Passes an object with segmentX and segmentY properties.
  • segmentwillchange Fires as soon as the scroll position crosses a segment boundary, during a scroll movement. Passes an object with segmentX and segmentY properties.
  • reachedstart Fires when the scroll position reaches the top or left of a scroller. Passes an object with an axis property indicating whether the x or y axis reached its start position.
  • reachedend Fires when the scroll position reaches the bottom or right of a scroller. Passes an object with an axis property indicating whether the x or y axis reached its end position.

Compatibility

FTScroller supports input via mouse or touch on the following browsers:

  • Apple Mobile Safari (iOS 3.2+ confirmed, best after 4.0+)
  • Google Android Browser (Android 2.2+ confirmed)
  • Microsoft Internet Explorer 10 (Windows 8 RTM confirmed)
  • RIM BlackBerry PlayBook (2.0 confirmed, 1.0 should be fine)
  • Most modern desktop browsers (IE 9+, FF 4+, Safari 3+, Chrome 1+, Opera 11.5+ - ECMAScript 5 getters and setters are currently used)

Tips and tricks

  • If you are putting together the DOM in JavaScript using HTML or a template, it's advantageous to use the prototype methods for getPrependedHTML and getAppendedHTML to add the FTScroller HTML at the same time. If the elements are added to the very start and very end of the content within the element passed in to the constructor (ignoring whitespace), the Scroller instantiation will detect this and skip the DOM manipulation step, leading to faster instantiation without an additional layout.
  • If scrolling is going to only occur along one axis, setting scrollingX or scrollingY to false as part of the construction options skips creating of the corresponding DOM element, saving memory (particularly when using hardware acceleration).
  • Depending on your CSS, you may find that you can't scroll quite to the bottom of your content. This is typically a collapsing margin issue โ€” the contents are measured, then wrapped in additional elements, but the margins spilling out of the contents can't be measured. If you see this, an easy fix is typically to put overflow: hidden either your scrollable element or its contents; that will act as a boundary for margins so everything can be measured, and typically has no effect on appearance when applied to the content as the scrollable content won't have dimensional limits.

Credits and collaboration

The lead developer of FTScroller is Rowan Beentje at FT Labs. All open source code released by FT Labs is licenced under the MIT licence. We welcome comments, feedback and suggestions. Please feel free to raise an issue or pull request. Enjoy.

ftscroller's People

Contributors

floriancargoet avatar georgecrawford avatar jimcresswell avatar kornelski avatar mattcg avatar matthew-andrews avatar musshush avatar orangemug avatar pgherveou avatar rdsubhas avatar robbiemccorkell avatar rowanbeentje avatar samgiles avatar smithl avatar wheresrhys avatar wilsonpage avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ftscroller's Issues

New function: scrollToElement

Hi,

you may want to add a new public function: scrollToElement, adapted from _childFocused:

var scrollToElement = function scrollToElement(element, animationDuration) {
    var offset, axis;
    var focusedNodeRect = _getBoundingRect(element);
    var containerRect = _getBoundingRect(_containerNode);
    var edgeMap = { x: 'left', y: 'top' };
    var dimensionMap = { x: 'width', y: 'height' };

    // If an input is currently being tracked, ignore the focus event
    if (_inputIdentifier !== false) {
        return;
    }

    // Get a duration
    var duration = animationDuration || 0;
    if (duration === true) {
        duration = Math.sqrt(Math.abs(_baseScrollPosition[axis] - targetPosition)) * 20;
    }
    for (axis in _scrollableAxes) {
        if (_scrollableAxes.hasOwnProperty(axis)) {

            // Set the target offset to be in the middle of the container, or as close as bounds permit
            offset = -Math.round((focusedNodeRect[dimensionMap[axis]] / 2) - _lastScrollPosition[axis] + focusedNodeRect[edgeMap[axis]] - containerRect[edgeMap[axis]]  - (containerRect[dimensionMap[axis]] / 2));
            offset = Math.min(0, Math.max(_metrics.scrollEnd[axis], offset));

            // Perform the scroll
            _setAxisPosition(axis, offset, duration);
            _baseScrollPosition[axis] = offset;
        }
    }
};

_childFocused can then call this new function.

Visible scrollbars

Is there a way of having the scrollbars visible all the time, and not fade away?

Scroll delay android 4.1.2/4.2.2

Using the following devices

  • Samsung Galaxy SIII - Android 4.1.2
  • Nexus S - Android 4.1.2
  • Samsung Galaxy S - 4.2.2

On both the Chrome and the default web browser there is a slight delay when scrolling.

The touch event triggers about a second after I touch the screen. This can cause small jumps when flicking up and down and when trying to stop the scrolling (by flicking, and then holding the finger down). The issue does not appear on the HTC Desire HD (Android 2.3.5), unfortunately I do not have any other devices I can test this with.

The issue occurs on all the examples in the FTScroller's readme file.

Not working on Opera

Not working on opera 12 on linux ubuntu 12.04. Haven't checked on windows, but probably the case too.

Textarea problem in IE

On IE11 you need to double click the textarea before you can type in it. It either immediately looses focus or doesn't get it.
With IE9 & 10, the problem is even worse. To be able to type in the textarea you need to right-click it. If the right-click doesn't do it, then right-click and select "select all".
You can loose focus by right-clicking somewhere else.

That's not all though. Once you have focus on the textarea, left click inside the textarea and hold it down. Then move your mouse downwards, after that release. Move your mouse and you'll notice you're stuck in dragging.

Very simple fiddle: http://jsfiddle.net/VX968/4/

text select in scroller without horizontal scrolling

I have a list scroller where the width is entirely contained in its container. There is no horizontal scrolling, and this is set in the options for the scroller ('scrollingX: false').

I would like to be able to select text from the list items.

As it is, FTScroller catches all mouse move events so that there is no selection.

Is there a way to enable text selection?

[Performance] Only add 3d acceleration onto elements that actually scroll

I know we add uses3d-esque hacks onto FT scroller elements to push the scroll rendering onto the GPU but that feels a little wasteful in cases where FT Scroller knows that that element will never scroll.

screen shot 2013-11-10 at 00 22 25

To recreate:

  • use Chrome's to "Show Composited layer borders" to identify the hardware accelerated layers. (Remove all of the ones on the accordions)
  • Give the FT scroller element and accordion title ids so you can trigger events / manipulate properties on them with JS to prevent timeline getting filled with noise.
  • Use timeline to record, run the commands show in screenshot into the console.

Conclusion: don't make layers unnecessarily.

How best to dynamically load content for very large scrollers?

Hi,

I'm trying to figure out the best way of dynamically adding elements.

One method is to have a

representing each "page" of content and only load the content when it is in view. The problem with this is, if I have, say 200 pages, that will mean the width of the scroller will be 200 * section width. A 3D transform on a scroller of that width will use up a lot of memory, perhaps too much memory than the browser can cope with. In my case it needs to work on mobile, so I don't have that much memory to play with.

Other solutions could be:

  • Limit the number of
    elements and move nodes depending of the direction of swiping
  • Limit the number of
    elements and move the content within the nodes depending of the direction of swiping
  • Limit the number of
    elements and use CSS absolute positioning to move the nodes depending on the direction of swiping

I'm interested to find out if others have come across this problem and what your solutions have been.

Cheers,
Andrew

It seems that FTScroller is having problems while running on Android version 3.2 devices.

Hi Team,

First of all I would like to thank you all for your efforts to bring such a nice tool to make others life .

I'm working on an app, which is being developed using Jquery Mobile and other stuff required to develop a hybrid application to support cross platform compatibility.

Initially I have been testing the FTScroller functionality on Android v4.0 so could not observe the issue. Recently I started testing the app on Android v3.2 and I was surprised that, it's not working on devices running on Android v3.2.

Please have a look at the errors I'm getting while running the code in Android v3.2.

06-11 17:39:37.668: E/Web Console(400): SyntaxError: Parse error at file:///android_asset/resource/lib/ftscroller.js:2182

Whenever it tries to execute the piece of code given below, throws the error that, Can't find variable FTScroller as given below.

Code: var scroller = new FTScroller(document.getElementById('wrapper'), {
scrollingX: false
});

Error: 06-11 17:39:59.279: E/Web Console(400): ReferenceError: Can't find variable: FTScroller at file:///android_asset/resource/js/controller/formsScreenController.js:99

Could you suggest me the fix for this issue please?

Thanks,

Setting up multiple scrollers causing 'layout thrashing'

Below you can see a timeline graph of three scrollers being set up. Each setup operation causes a read and a write operation to the DOM, and therefore results in three layouts/reflows in this particular frame, blowing our 60fps frame budget.

screen shot 2013-10-11 at 11 52 55

Options

  • A. Offer a more granular API that gives the user the option of batching the reads and writes to prevent this thrashing, e.g. scroller.calc() and scroller.set() (favoured).
  • B. Use a library like FastDom internally (easiest).

updateOnChanges bug ?

Not sure if this is a bug, but here's what confusing me:

In the horizontalpaged-strict.html example, a scroller is created and, according to documentation, updateOnChanges is set to true by default.

However, if I manually delete one of the scroller elements (section), the scroller's dimensions are not updated, ie : after the last element ("page 6), I can still scroll one "page" to the right

Support for irregular segment width?

My scrollable content has segments that are not a uniform width. Is there a way I can set individual segment sizes and not have a single value for each segment? Thank you so much for your support!

ftscroller allows multiple finger touch to scroll

Hi,

ftscroller allows more than one finger touch to scroll, generally swipe/scroll restricted for single finger scroll.

any way to restrict only single finger to scroll ftscroller?

regards,
Ramkumar P

Support for nested scrollers ?

The nested scrollers example provided shows 2 vertical scrollers inside 1 horizontal scroller.

Is it possible to have 1 horizontal scroller inside another horizontal scroller, or one vertical inside another vertical scroller ?

I may be wrong, but it looks like it is currently not possible to do it.

This may be due to events on the nested scroller being captured by the containing scroller, in which case, this could be solved by just supressing event bubbling from any scroller ?

Observations about scrolling physics

I thought I'd provide some feedback on the feel of ftscroller. While animating, the experience is quite smooth - better than most examples of scrolling that I see. However, there seems to be a couple of issues.

  1. The bounce could stand to be more natural. In most iOS apps, when you hit the bounce wall, there is no noticeable discrete change in velocity, rather the bounce is gracefully absorbed. Also, when pulling to refresh iOS apps don't typically create the type of long delayed rubber banding that I see in ftscroller. I've attempted to change some of the hardcoded cubic bezier parameters for bounce but I can't seem to reproduce a more iOS feel. Have you had any luck in doing so?
  2. I've noticed an interesting behavior when accumulating momentum and scrolling. It seems like continued swipes momentarily decrease velocity (while touchmoving). I know this is one of the things that creates a physical feel, but I think that the amount of weight placed on the physical touches while in the middle of scrolling is greater than what I feel in native iOS apps. It's almost like my touchmoves are adding friction to the scrolling physics, yet that friction doesn't increase the velocity of scrolling as much as I expect. Maybe there's something completely different happening but this is the effect that I perceive. Could it be that continued swipes need to be smoothed out more while scrolling? (Or less weight/friction applied to touchmoves while scrolling).

Have you or anyone else found some very nice CubicBezier constants to try?

IE 10 scroll problem

This script is great, works like a charm on Android and iPhones, but i have found one problem with IE 10 on my Lumia 820.

I have 2 vertical scollers inside 1 horizontal. When the page loades the first vertical scroller scrolls fine. When i swipe to the left and gets to vertical scroller 2 the scrolling inside vertical scroller 2 also works. But when i swipe back to vertical scroller 1 the vertical scrolling stops on both vertical scrollers. Why is that?

As i said, this problem only occurs on IE 10.

Can this be coded around?

Feel free to try my code: http://m.vasabladet.fi/new/ft/

Actually the same issue accurs on the ft demo: http://ftlabs.github.com/ftscroller/examples/galleryscrollers.html

Hopeful for answers

/Patrik

Link to specific scroller

First of all i would like to say i love the ftscroller, found it way better than other scrollers i have worked with.

I use the ftscroller with pagination with one horizontal scroller and several vertical scrollers within, as i call pages.

I would like to let my users jump between the "pages" (vertical scrollers). How can i link to a specific scroller? Is there a way of achieving this?

Grateful for answer.

IE 11 support

Thanks for a great product.

Everybody knows how IE sucks but i still have to pull the question. Do you have any plans to get the scroller to work proper in IE 11?

scroll event and scrolltop - touch device

hi guys, first of all thanks for this excellent scroller lib
just like native scrolling, "scroll" event isnt fired on touch devices when your finger isnt touching the screen but the screen is still scrolling.
thus when you try to access scrollTop in a setInterval loop scrollTop value is wrong

So two questions ;-)

  • Can we get the scroll event to be fired when the screen is still scrolling?
  • Can the real scrollTop value be exposed?

using ftscroller to build a carousel

Sorry for posting an issue what is actually a mere question:

Am I correct in thinking FTScroller would be great to build a carousel on top of?

Horiziontal scrolling would work on touch devices with swiping (with snap-to-grid or whatever it's called enabled, so only 1 element per swipe is moved) while it needs to fallback to clicks on non-touch devices.

Anyone already tackled something like this? If not, I'm willing to take a shot at it and share.

Geert-Jan

Add support for Firefox Mobile/Tablet

Currently, ftscroller uses "document.hasOwnProperty('ontouchstart')" to test for touch support. Firefox Mobile/Tablet on Android report false, although they have touch support. Test for "ontouchstart' in window" would report true in Firefox.

Provide alternative for ECMAScript5 setters

Dolfin 3.0 / Bada 2.0 on Samsung GT-S8600 (Wave III) and RIM Browser 7.1.0.714 on a Blackberry 9900 don't like the ECMAScript5 setters. So ftscroller.js cannot be parsed. You may want to provide an alternative to ECMAScript5 setters.

Form control problems with Android 2.3*

There are problems with form controls (e.g. text input, select) on Android 2.3* native browsers. They don't open the keyboard or the 'option picker' UI control. Looks like this is caused by the CSS transformations.

I tried to solve this by adding a variant using top/left instead of CSS transformations. This is slower but seems to work with form controls.

Fixing Dolfin2 problem with touchmove event

Samsung's Dolfin 2 browser has a problem with touchmove events: clientY seems to be increased by the difference between pageY and clientY at touchstart. I triy to workaround this problem by addiing

var _isDolfin2 = (/Dolfin\/2\./).test(navigator.userAgent);

in the outermost closure,

var _diffY;

in the FTScroller constructor,

_diffY = _isDolfin2 ? touchEvent.pageY - touchEvent.clientY : 0;

at the end of _onTouchStart,

 _updateScroll(touchEvent.clientX, touchEvent.clientY - _diffY, moveEvent.timeStamp, moveEvent);

instead of

_updateScroll(touchEvent.clientX, touchEvent.clientY, moveEvent.timeStamp, moveEvent);

in _onTouchMove, and

_diffY = 0;

at the end of _onTouchEnd.

module.exports is empty when using browserify

Hi, Thanks for the wonderful library! I'm using Browserify to package and running it in Chrome. But the FTScroller object is empty!

var FTScroller = require("ftscroller");
console.log(FTScroller); // empty object!

I believe this is because of the var module declaration in this line which could be messing up with the existing module object.

I've found your other excellent library ftlabs/FastClick to use a very nice way to define the module. I've tested with that and it works like a charm. Can we use that same approach here too?

Chrome v 33.0.1750.152, Browserify v 3.38.0, Node v 0.10.26, NPM v 1.4.3

Applying one scroller to all instances of same element

Is it possible to apply the same scroller to many identical elements that are in a row? I'd like to do something like this:

var nestedScroller = new FTScroller(document.querySelector('.eventWrap'), {
scrollbars: true,
scrollingX: false,
scrollingY: true,
updateOnWindowResize: true
});

However, this only adds an FTScroller to the first element with the class "eventWrap" that it finds.

Pagination adds gaps between panes and a blank page at the end

I'm using ftscroller to write a small app that has several vertical scrollers inside a horizontal one and its not paginating the content correctly. The problem is that when I move to a higher number page part of the previous one is still visible on the left, it seems like the scroller is not assigning the pages the correct width, although it assigns the total width of all the pages correctly. You can check this behavior on your paginated demo code, just add some more pages and you will see it.

Thanks

Update scrollable dimensions when filtering content

I have a UL containing a number of items that I am filtering using jQuery. The jQuery code simply uses fadeOut to hide the li as the user types into an input field.

As the list is reduced the scrollable area remains at the original height. Is there a method to update the height on keyup?

Many thanks.

Limit bounce effect

I've been digging in the source code and trying to figure out a way to limit the bounce effect.

As far as I know the bounce animation is dependable on the fling which makes it possible to bounce the page on almost the entire screen.

What I would like to accomplish is to limit that bounce to, let's say, half the screen size (for example).

The bezier curve on the bounce only have effect on the animation speed so if someone could point me in the right direction that would be great.

Don't preventDefault() for swipe movements orthogonal to scroller direction

Consider a horizontal scroller (scrollingY: false) in a vertically scolllable page. Currently vertical swipe movements on the scroller will not trigger the native page scroll, because of
javascript rawEvent.preventDefault(); in _updateScroll.

For scrollers with scrollingY: false you could try to restrict rawEvent.preventDefault(); to only mainly horizontal swipe movements and correspondingly to mainly vertical swipes for scrollers with scrollingX: false.

Why is the 'scrollend' event not triggered when scrolling is canceled?

Hello,

I have been surprised to see that the scrollend event was not fired if the user cancels the scrolling, I don't understand the choice behind it. It is useful to know when the scroll has ended, and even if the user cancels it by tapping the screen while the scrolling takes place, I think it can still be considered as a scrollend scenario. Could you explain please?

Thank you for your help,

Jean-Francois

Scrolling of ftscroller_container after click on label element

In some browsers, e.g. Firefox Mobile, but also some Android Native browsers, the ftscroller_container is moved after a label element is clicked. In a vertical scroller, the scrollTop property is changed, so that parts of the scroller can no longer be scrolled to.

I tried to work around this problem by adding a new function

/* Click on label element changes scrollTop/scrollLeft in some browsers. */
var _removeScrollEdge = function _removeScrollEdge(event) {
    var axis;
    for (axis in _scrollableAxes) {
        if (_scrollableAxes.hasOwnProperty(axis)) {
            if (axis === 'y') {
                if (_containerNode.scrollTop > 0) {
                    _containerNode.scrollTop = 0;
                }
            } else if (axis === 'x') {
                if (_containerNode.scrollLeft > 0) {
                    _containerNode.scrollLeft = 0;
                }
            }
        }
    }
};

and registering it via

_containerNode._ftscrollerToggle('scroll', _removeScrollEdge, true);

in _toggleEventHandlers.

Video Display

Scroll works great in browser and on a desktop AIR app I have developed. One issue that I'm curious if you have come across before - mp4 videos don't load when scroll is in place. They just disappear. Conflict in video player and ftscroller?

Scrollbar can't be used as scroll handle

In many scrollbar implementations, including OSX and iOS, you can click/touch the scrollbar "marker" and use it as a handle to drag it up or down (assuming vertical scroll). This doesn't seem possible with ftscroller, or am I missing something? I can scroll the content, but there is no "handle".

If I was to implement this feature myself, do you have any hints or pointers to specific code?

Scroll using buttons

For users on a desktop PC I would like to have the scroller advance left/right with the click of a button. I think this carousel effect could be achieved using the scrollTo method but I am unsure exactly how. Please could you give me some pointers?

segmentwillchange event fired incorrectly ?

I am looking at the "Horizontal paged strict version".

If I attach segmentwillchange event as follows:

segmentwillchange = function(changeObject) {
console.log(changeObject);
};
scroller.addEventListener("segmentwillchange", segmentwillchange);

If I scroll while maintaining mousedown, the event is fired correctly when the segment threshold is crossed.

However, if I scroll "quickly" (ie: mousedown, quick movement left or right, mouseup), then the event fires only when the scroller has finished its animation, not when the threshold is crossed.

one page two scroller

a large container,has a scrollerY,
and the large container has an inner small container,the small has a scrollerY too,
then the small container scroller not work

Mouse controls

Just been experimenting with the ftscroller with the latest Firefox and the mouse dragging doesn't seem to be working at all on any of the demos.

Seems fine in Chrome/Safari though!

is there a 'refresh' method for the scroller

I have a ftscrollable div with updateOnChanges = true.
There are some sub-elements of the div that I hide / show at runtime.

The scroller does not appear to respond to the (implicit) new size of the div caused by hiding / showing.

Is there a way to force 'refresh', or force whatever action is normally triggered by a genuine content change ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.