Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

Commit

Permalink
Merge pull request #22 from imanhodjaev/fixing-issueno21
Browse files Browse the repository at this point in the history
Fixing issueno21
  • Loading branch information
sultaniman authored Oct 19, 2017
2 parents e5ccaa3 + 023b0b0 commit f21135b
Show file tree
Hide file tree
Showing 13 changed files with 180 additions and 198 deletions.
23 changes: 12 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,18 @@ cache:
yarn: true

env:
# we recommend new addons test the current and previous LTS
# as well as latest stable release (bonus points to beta/canary)
- EMBER_TRY_SCENARIO=ember-lts-2.8
- EMBER_TRY_SCENARIO=ember-lts-2.12
- EMBER_TRY_SCENARIO=ember-release
- EMBER_TRY_SCENARIO=ember-beta
- EMBER_TRY_SCENARIO=ember-canary
- EMBER_TRY_SCENARIO=ember-default
global:
# See https://git.io/vdao3 for details.
- JOBS=1
matrix:
# we recommend new addons test the current and previous LTS
# as well as latest stable release (bonus points to beta/canary)
- EMBER_TRY_SCENARIO=ember-lts-2.8
- EMBER_TRY_SCENARIO=ember-lts-2.12
- EMBER_TRY_SCENARIO=ember-release
- EMBER_TRY_SCENARIO=ember-beta
- EMBER_TRY_SCENARIO=ember-canary
- EMBER_TRY_SCENARIO=ember-default

matrix:
fast_finish: true
Expand All @@ -33,9 +37,6 @@ before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash
- export PATH=$HOME/.yarn/bin:$PATH

cache:
yarn: true

install:
- yarn install --no-lockfile --non-interactive

Expand Down
8 changes: 7 additions & 1 deletion addon/components/perfect-scroll/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,13 @@ export default Ember.Component.extend({
this._super(...arguments);

run.schedule('afterRender', () => {
window.Ps.initialize(this.getElementForPs(), this._getOptions());
let element = this.getElementForPs();
window.Ps.initialize(element, this._getOptions());

// reflect initial scrollLeft and scrollTop positions to the element
element.scrollLeft = this.get('scrollLeft');
element.scrollTop = this.get('scrollTop');

this.bindEvents();
this.triggerLifeCycleAction('initialized');
});
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ember-perfectscroll",
"version": "0.1.16",
"version": "0.1.17",
"description": "The default blueprint for ember-cli addons.",
"keywords": [
"ember-addon"
Expand All @@ -18,27 +18,27 @@
"test": "ember try:each"
},
"dependencies": {
"ember-cli-babel": "^6.3.0",
"ember-cli-babel": "^6.6.0",
"ember-cli-htmlbars": "^2.0.1",
"ember-cli-htmlbars-inline-precompile": "^1.0.0",
"perfect-scrollbar": "^0.8.1"
},
"devDependencies": {
"broccoli-asset-rev": "^2.4.5",
"ember-ajax": "^3.0.0",
"ember-cli": "~2.15.1",
"ember-cli": "~2.16.2",
"ember-cli-dependency-checker": "^2.0.0",
"ember-cli-eslint": "^4.0.0",
"ember-cli-inject-live-reload": "^1.4.1",
"ember-cli-qunit": "^4.0.0",
"ember-cli-shims": "^1.1.0",
"ember-cli-sri": "^2.1.0",
"ember-cli-uglify": "^1.2.0",
"ember-cli-uglify": "^2.0.0",
"ember-disable-prototype-extensions": "^1.1.2",
"ember-export-application-global": "^2.0.0",
"ember-load-initializers": "^1.0.0",
"ember-resolver": "^4.0.0",
"ember-source": "~2.15.0",
"ember-source": "~2.16.0",
"loader.js": "^4.2.3"
},
"engines": {
Expand Down
15 changes: 9 additions & 6 deletions testem.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ module.exports = {
'Chrome'
],
browser_args: {
Chrome: [
'--disable-gpu',
'--headless',
'--remote-debugging-port=9222',
'--window-size=1440,900'
]
Chrome: {
mode: 'ci',
args: [
'--disable-gpu',
'--headless',
'--remote-debugging-port=9222',
'--window-size=1440,900'
]
},
}
};
4 changes: 2 additions & 2 deletions tests/dummy/app/app.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import Ember from 'ember';
import Application from '@ember/application';
import Resolver from './resolver';
import loadInitializers from 'ember-load-initializers';
import config from './config/environment';

const App = Ember.Application.extend({
const App = Application.extend({
modulePrefix: config.modulePrefix,
podModulePrefix: config.podModulePrefix,
Resolver
Expand Down
4 changes: 2 additions & 2 deletions tests/dummy/app/router.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Ember from 'ember';
import EmberRouter from '@ember/routing/router';
import config from './config/environment';

const Router = Ember.Router.extend({
const Router = EmberRouter.extend({
location: config.locationType,
rootURL: config.rootURL
});
Expand Down
3 changes: 2 additions & 1 deletion tests/dummy/app/templates/index.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{{#perfect-scroll scrollId='boo' lifeCycleEventOccurred=(action 'lifeCycleEventOccurred') scrollTop=50 ps-y-reach-end=(action 'yReachEnd') ps-scroll-x='scrollX' ps-scroll-y='scrollY' as |ps|}}
{{#perfect-scroll scrollId='myPerfectScroll' lifeCycleEventOccurred=(action 'lifeCycleEventOccurred') scrollTop=150
scrollLeft=100 ps-y-reach-end=(action 'yReachEnd') ps-scroll-x='scrollX' ps-scroll-y='scrollY'}}
<div class="content">
</div>
{{/perfect-scroll}}
Expand Down
2 changes: 1 addition & 1 deletion tests/dummy/config/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ module.exports = function(environment) {
}

if (environment === 'production') {

// here you can enable a production-specific feature
}

return ENV;
Expand Down
4 changes: 2 additions & 2 deletions tests/helpers/destroy-app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Ember from 'ember';
import { run } from '@ember/runloop';

export default function destroyApp(application) {
Ember.run(application, 'destroy');
run(application, 'destroy');
}
4 changes: 1 addition & 3 deletions tests/helpers/module-for-acceptance.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { module } from 'qunit';
import Ember from 'ember';
import { resolve } from 'rsvp';
import startApp from '../helpers/start-app';
import destroyApp from '../helpers/destroy-app';

const { RSVP: { resolve } } = Ember;

export default function(name, options = {}) {
module(name, {
beforeEach() {
Expand Down
9 changes: 5 additions & 4 deletions tests/helpers/start-app.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import Ember from 'ember';
import Application from '../../app';
import config from '../../config/environment';
import { merge } from '@ember/polyfills';
import { run } from '@ember/runloop';

export default function startApp(attrs) {
let attributes = Ember.merge({}, config.APP);
attributes = Ember.merge(attributes, attrs); // use defaults, but you can override;
let attributes = merge({}, config.APP);
attributes = merge(attributes, attrs); // use defaults, but you can override;

return Ember.run(() => {
return run(() => {
let application = Application.create(attributes);
application.setupForTesting();
application.injectTestHelpers();
Expand Down
23 changes: 23 additions & 0 deletions tests/integration/components/perfect-scroll/component-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,29 @@ test("it updates perfect scroll via perfect-scroll-controller mixin", function (
assert.equal(psYReachEndEventCount, 1, 'The event handling should have been triggered after perfect scroll update is triggered.');
});

test('initial scrollLeft and scrollTop positions are respected', function (assert) {
this.render(hbs`
<style>
.ps-content { position:relative; margin:0px auto; padding:0px; width: 100px; height: 100px; overflow: auto}
.ps-content .content {width: 400px; height: 400px}
</style>
{{#perfect-scroll scrollId='first'}}
<div class="content"></div>
{{/perfect-scroll}}
{{#perfect-scroll scrollId='second' scrollTop=20 scrollLeft=200}}
<div class="content"></div>
{{/perfect-scroll}}`);

let firstElement = this.$('#first');
let secondElement = this.$('#second');

assert.equal(firstElement.scrollLeft(), 0, "First element's initial scroll left should have been 0 since value is not passed from outside");
assert.equal(firstElement.scrollTop(), 0, "First element's initial scroll top should have been 0 since value is not passed from outside");

assert.equal(secondElement.scrollLeft(), 200, "Second element's initial scroll left should have been 20 since value is passed from outside");
assert.equal(secondElement.scrollTop(), 20, "Second element's initial scroll top should have been 20 since value is passed from outside");
})

/**
* Corresponding events will be triggered multiple times by the event firing test; hence we need a way to store number of
* times each individual event is fired.
Expand Down
Loading

0 comments on commit f21135b

Please sign in to comment.