Code Monkey home page Code Monkey logo

ember-scrollable's Introduction

Ember Scrollable

Ember Version Npm Version Code Climate Build Status

A simple scrollbar implementation inspired by Trackpad Scroll Emulator.

Check out the demo

Installation

  • ember install ember-scrollable

Basic Usage

{{! app/templates/index.hbs }}

{{#ember-scrollable}}
  Some long content...
{{/ember-scrollable}}

Configuring the Component

The component accepts the following options:

  • horizontal: Enables horizontal scrolling (default: false)
  • vertical: Enables vertical scrolling (default: true if horizontal is unset)
  • autoHide: Enables auto hiding of the scrollbars on mouse out (default: true)
  • scrollTo: Set this property to manually scroll to a certain position (if in single bar mode)
  • scrollToX: Set this property to manually scroll to a certain position in the horizontal direction
  • scrollToY: Set this property to manually scroll to a certain position in the vertical direction
  • onScroll(scrollOffset, event): action triggered whenever the user scrolls, called with the current scrollOffset and the original scroll event
  • onScrolledToBottom: action triggered when user scrolled to the bottom

Advanced Usage

{{#ember-scrollable horizontal=true vertical=true}}
  content that is wide and long.
{{/ember-scrollable}}

Developing

Setup

  • git clone https://github.com/alphasights/ember-scrollable.git
  • npm install && bower install

Running

  • ember server

Linting

  • npm run lint:js
  • npm run lint:js -- --fix

Running tests

  • ember test – Runs the test suite on the current Ember version
  • ember test --server – Runs the test suite in "watch mode"
  • ember try:each – Runs the test suite against multiple Ember versions

Running the dummy application

For more information on using ember-cli, visit https://ember-cli.com/.

License

This project is licensed under the MIT License.

ember-scrollable's People

Contributors

acorncom avatar alexander-alvarez avatar andyhot avatar baltazore avatar bekzod avatar blimmer avatar buschtoens avatar crudo1f avatar dependabot[bot] avatar donaldwasserman avatar efx avatar ember-tomster avatar eugeniodepalo avatar fran-worley avatar gaurav0 avatar jrjohnson avatar lelelyons avatar lonelyghost avatar marcoumpierrez avatar melodiehardwick avatar offirgolan avatar patrickberkeley avatar piotrpalek avatar richard-viney avatar taras avatar thijsvdanker 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

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

ember-scrollable's Issues

ember-version-checker appears to need bumped (trying [email protected])

ember build is failing in my project when I have upgraded to [email protected]:

ember build -w t
DEPRECATION: Overriding init without calling this._super is deprecated. Please call `this._super.init && this._super.init.apply(this, arguments);` addon: `ember-get-helper`
    at Function.Addon.lookup (fakepath/node_modules/ember-cli/lib/models/addon.js:996:27)
⠋ BuildingInvalid Version: undefined
TypeError: Invalid Version: undefined
    at new SemVer (fakepath/node_modules/ember-scrollable/node_modules/semver/semver.js:281:11)
    at compare (fakepath/node_modules/ember-scrollable/node_modules/semver/semver.js:571:10)
    at Function.lt (fakepath/node_modules/ember-scrollable/node_modules/semver/semver.js:605:10)
    at DependencyVersionChecker.(anonymous function) [as lt] (fakepath/node_modules/ember-scrollable/node_modules/ember-cli-version-checker/index.js:68:26)
    at Class.treeFor (fakepath/node_modules/ember-scrollable/index.js:27:31)
    at Class.superWrapper [as treeFor] (fakepath/node_modules/ember-cli/node_modules/core-object/lib/assign-properties.js:32:18)
    at fakepath/node_modules/ember-cli/lib/models/addon.js:245:34
    at Array.map (native)
    at Class.eachAddonInvoke (fakepath/node_modules/ember-cli/lib/models/addon.js:243:24)
    at Class.treeFor (fakepath/node_modules/ember-cli/lib/models/addon.js:329:22)

I'll try to isolate this to make sure it is that package

Number.parseInt(offset, 10) not a function

I'm using your module through ember-light-table, and I'm getting this error when testing through phantomjs: "TypeError: undefined is not a function (evaluating 'Number.parseInt(offset, 10)')", at the function call here.

I'm not sure what would cause Number.parseInt() to be undefined.

does not work on IE11

Hello

the bug is due to this line of code

offset = Number.parseInt(offset, 10)

on IE11 Number.parseInt is undefined

object doesn't support property or method 'parseInt'

preserving scrollTop for infinite scroll

When I have an scrolledToBottom action that re-renders the scrollable content with more elements, the scrollTop is always set such that the scrollbar is at the bottom of the newly expanded scrollable content area, and it will cause scrolledToBottom to be triggered again and so forth.

How do I preserve the scrollTop when the scrollable content area resizes?

Consider Putting Up For Adoption

Hello -

Based on the conversation in #98, what would @alexander-alvarez or anyone else at alphasights thing about transfering this addon to: https://github.com/adopted-ember-addons

That way it can transfer ownership, maintenance, in a secure and transparent way with:

  1. a relatively trusted group to steward security updates
  2. More eyes to be able to triage issues, etc
  3. Gets this off your hands but maintains stability for consumers

Here are the program guidelines: https://github.com/adopted-ember-addons/program-guidelines/blob/master/README.md

Bug with double scroll

There is a bug when there are vertical and horizontal scrollers on the screen like you have in your "Double Scroll" demo (https://alphasights.github.io/ember-scrollable/).

To reproduce in your demo:
Move vertical scroll to the middle and then move horizontal scroll but with the mouse click and then drag left or right (actually, dragging left or light is not necessary, just the click on horizontal scroll is enough). After the click the content will move to the top while vertical scroll will stay in the middle.

Actually, if you try randomly clicking on scrollers, it just seems there are some weird issues that pop up.

Native and virtual scrollbar visible in Internet Explorer

<div style="height: 50vh; width: 80%;">
  {{#ember-scrollable}}
    <div style="height: 300vh; background: linear-gradient(0deg, #009245, #FCEE21);">
    </div>
  {{/ember-scrollable}}
</div>

image

Tested in Internet Explorer 11 with Edge rendering engine on Windows 7. Also happens with the IE 10 and IE 9 rendering engine.

Recalculate on viewport change

Currently, the scrollbar is recalculated when the window is resized which works great but I believe that it should also be recalculated when the height/width of the viewport has changed.

Let me give you an example:

In my app I have a filter toggle which when clicked, expands out a div with some options. When that button is clicked again, it hides the previously opened div. On both click events, the viewport height has changed and the scrollbars have not updated, leaving an awkward empty whitespace.

When I resize the screen, the scrollbar gets recalculated and all is fixed.

[IE] failing and freezing tests

Running tests in IE is a complete PITA as some cases, besides failing, seem to take forever and freeze the whole browser.

image
image
image
image
image

cannot use jquery draggable inside ember-scrollable component

Hello

I am using jquery ui draggable inside scrollable component and it prevents my draggable elements from dragging. I have search and found the issue inside your add-on:

  /**
  * Drag scrollbar handle
  */
  drag(e) {
    return;
    e.preventDefault();

    this.get('scrollbar').drag(e);
  },

this code is preventing it from working and I guess it should not be global for entire ember-scrollable component, and you can move this to be prevented only on the handle.

Thanks
Ashot Vardanyan

[Firefox] "no-overflow => overflow => no-overflow" test fails

Acceptance | ember-scrollbar: When element resized from no-overflow => overflow => no-overflow, no scrollbar is visible on mouseover (3, 4, 7)

> there is no overflow as 18 < 200px
  Expected: 18
  Result: 19

> there is overflow as 494 > 200px@ 1247 ms
  Expected: 494
  Result: 509

> failed
  Expected: 18
  Result: 19

image

jQuery dependency

Hi,

Right now this addon needs Ember's jQuery integration to be enabled as it uses this.$() in several places, as well as some jQuery functions.

This could be refactored to avoid mandating a dependency on jQuery, though in the meantime adding the @ember/jquery package as an explicit dependency might be a good first step.

Thoughts?

Internet Explorer 11 JS Errors on Demo Page

It seems like IE11 doesn't have some methods like parseInt defined.

How much work would it be to get this running in IE11, too? Is it just some fixing here and there or do you rely on newer browsers in depth?

Uncaught TypeError: Cannot read property 'setAttribute' of undefined

Hi! I just installed ember-scrollable using npm i [email protected] --save and included my code into:
{{#ember-scrollable onScrolledToBottom=(action 'log' 'Bottom reached!')}}
...TABLE CONTENT
{{/ember-scrollable}}

and got problem:
ember.debug.js:2532 Uncaught TypeError: Cannot read property 'setAttribute' of undefined
at DOMHelper.prototype.setAttribute (ember.debug.js:2532)

Can you please explain me, what the problem is?

Event Listeners not removed

In ember-scrollable.js you're registering three two event listeners on document.body and one on window. As far as I can see these event listeners aren't removed when the element is destroyed.

Action to trigger scroll.

I am stuck trying to add an action that triggers the scrollable content to scroll a specific direction, for a length.

actions: {
    next() {
      this.setProperties({
        scrollToX: 100,
      });
    }
}
    {{#ember-scrollable horizontal=true scrollTo=top}}
            <div class="item">
              <span>{{item}}</span>
            </div> 
    {{/ember-scrollable}}
    <div class="swiper-next" onclick={{action "next"}}>
      Next
    </div>

I have tried to change the property value, and that does not work. Is there something I need to do?

Missing handling of mouseLeave when mouse button pressed.

There is a problem with situation when dragging scrollbar and leaving the application area while still keeping mouse button pressed. After reentering into another portion of application viewport, the mousemove events are still consumed by scrollbar. Following code inserted into
"ember-scrollable\addon\components\ember-scrollable.js" helped to me:
..
mouseLeave(e){
if(e.buttons) {
this.endDrag(e);
}
}
..

Prevent scroll when the element is resizing

Hi there,
is it obligatory to have a ember-element-resize-detector as a dependency? And it could be very useful if it can save the position of scroll when the wrapping div is resizing.

Adding new maintainer

Can you please add @Baltazore as a contributor to this library? Also, can you please upgrade me to admin on this repo?

Or alternatively, can I move this repo to my organization?

Activate TravisCI for this repo

@Arkham to hookup this repo to TravisCI, TravisCI requires admin permissions on the organization. I don't have that, so could you please activate this repo on TravisCI?

Get max width property of scrollable area.

I am not able to get the width property on the scrollable area.

I have made paging controls, to allow user interactions for scrolling, and I need to get the max width of the area, so I stop the scrolling action. Any suggestions?

Horizontal scrolling isn't working

I spooled up a new ember project and everytime I copy your code from Demo. It never works. Any ideas? I'm trying to figure out the horizontal scroll only. Thanks in advance.

CODE:
{{#ember-scrollable horizontal=true}}

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
{{/ember-scrollable}}

Deprecation warning in Ember 3.0

DEPRECATION: ember-cli-babel 5.x has been deprecated. Please upgrade to at least ember-cli-babel 6.6. Version 5.2.8 located: site-xxx-> ember-light-table -> ember-scrollable -> ember-component-inbound-actions -> ember-cli-babel

Don't use Sass

Would you be open to a PR replacing Sass with PostCSS?

Downloading the binary tends to cause problems behind our corporate proxy.

Intermittent exception in integration tests

I occasionally see this exception in my integration tests:

Error: Uncaught TypeError: Cannot read property 'width' of undefined (http://localhost:7357/assets/vendor.js:169159)
    at global.onerror (http://localhost:7357/assets/test-support.js:8333:10)

and I tracked it down to the Scrollbar create method.

screen shot 2016-07-14 at 4 56 36 pm

Looks like there might be a "bail if destroyed" bit missing.

Scrolls don't appear when content is inserted

For example when using ajax to get some text.

component.js:

$.get({
	url: 'http://server.com/get-text',
	dataType: 'text'
}).then(data => {
	this.set('text', data)
});

component.hbs:

{{#ember-scrollable horizontal=true vertical=true}}{{text}}{{/ember-scrollable}}

It is necessary to wrap ember-scrollable into {{#if text}}{{/if}}.

Shared states

All instances of {{ember-scrollable}} appear to share state.

If I hover over one container, not only the scrollbar of this container fades in, but all other containers do the same. Also, when using scrollTo, all containers scroll to that position.

set scroll position?

I'm having some difficulty resetting the the scroll position to the top? I am dynamically updating the contents of the scrollable and would like to also manually reset its scroll position to the top.

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.