Skip to content

Commit

Permalink
Merge pull request #29 from mvdwg/ember_twiddle_issues
Browse files Browse the repository at this point in the history
Ember twiddle fixes
  • Loading branch information
san650 authored Feb 1, 2017
2 parents 56a4f54 + 0250139 commit a82f031
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 19 deletions.
17 changes: 9 additions & 8 deletions addon/animation.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Ember from 'ember';
import POINTER_DATA from './pointer-data';

const { $, RSVP } = Ember;

Expand All @@ -15,13 +16,13 @@ function sleep(milliseconds) {
});
}

function clickEffectBefore() {
pointer('#ember-testing').addClass('tsClick');
function clickEffectBefore(container) {
pointer(container).addClass('tsClick');
return sleep(200);
}

function clickEffectAfter() {
return sleep(500).then(() => pointer('#ember-testing').removeClass('tsClick'));
function clickEffectAfter(container) {
return sleep(500).then(() => pointer(container).removeClass('tsClick'));
}

function distance(a,b) {
Expand All @@ -42,7 +43,7 @@ function pointer(container) {
let pointer = $('#tsPointer', container);

if (!pointer.length) {
let $img = $('<img>', { src: '/telling-stories/pointer.png' });
let $img = $('<img>', { src: POINTER_DATA });
let $click = $('<span>', { id: 'tsPointerClickEffect'});
let $cursor = $('<span>', { id: 'tsPointer' });

Expand All @@ -66,10 +67,10 @@ function movePointerTo(target, container) {
offset.left = offset.left + width;
offset.top = offset.top + height;

let ms = delay(pointer('#ember-testing').offset(), offset, SPEED);
let ms = delay(pointer(container).offset(), offset, SPEED);

pointer('#ember-testing').offset(offset);
pointer('#ember-testing').css('transition', `top ${ms}ms cubic-bezier(0.4, 0, 1, 1), left ${ms}ms linear`);
pointer(container).offset(offset);
pointer(container).css('transition', `top ${ms}ms cubic-bezier(0.4, 0, 1, 1), left ${ms}ms linear`);

if(!isElementInView($target)) {
scrollToElement($target);
Expand Down
18 changes: 9 additions & 9 deletions addon/page-object-execution-context.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { buildSelector } from 'ember-cli-page-object';
import Animation from './animation';
import { findClosestValue } from 'ember-cli-page-object/-private/helpers';

const defaultContainer = '#ember-testing';
import Animation from './animation';

export default function TellingStoriesContext(pageObjectNode) {
this.pageObjectNode = pageObjectNode;
Expand Down Expand Up @@ -31,20 +31,20 @@ TellingStoriesContext.prototype = {
click(selector, container) {
/* global wait */
wait()
.then(Animation.movePointerTo(selector, container || defaultContainer))
.then(Animation.clickEffectBefore());
.then(Animation.movePointerTo(selector, container))
.then(Animation.clickEffectBefore(container));

/* global click */
click(selector, container);

wait().then(Animation.clickEffectAfter());
wait().then(Animation.clickEffectAfter(container));
},

fillIn(selector, container, text) {
/* global wait */
wait()
.then(Animation.movePointerTo(selector, container || defaultContainer))
.then(Animation.clickEffectBefore());
.then(Animation.movePointerTo(selector, container))
.then(Animation.clickEffectBefore(container));

/* global fillIn */
if (container) {
Expand All @@ -64,7 +64,7 @@ TellingStoriesContext.prototype = {

assertElementExists(selector, options) {
/* global find */
let result = find(selector, options.testContainer);
let result = find(selector, options.testContainer || findClosestValue(this.pageObjectNode, 'testContainer'));

if (result.length === 0) {
throw new Error("Ooops!");
Expand All @@ -89,7 +89,7 @@ TellingStoriesContext.prototype = {
selector = buildSelector(this.pageObjectNode, selector, options);

/* global find */
result = find(selector, options.testContainer);
result = find(selector, options.testContainer || findClosestValue(this.pageObjectNode, 'testContainer'));

if (result.length === 0) {
throw new Error("Ooops!");
Expand Down
3 changes: 3 additions & 0 deletions addon/pointer-data.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion blueprints/telling-stories/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = {

return this.addAddonsToProject({
packages: [
{ name: 'ember-cli-page-object', version: '^1.6.0' }
{ name: 'ember-cli-page-object', version: '^1.8.0' }
]
});
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"ember-cli-htmlbars-inline-precompile": "^0.3.3",
"ember-cli-inject-live-reload": "^1.4.1",
"ember-cli-jshint": "^2.0.1",
"ember-cli-page-object": "^1.6.0",
"ember-cli-page-object": "1.8.0",
"ember-cli-qunit": "^3.0.1",
"ember-cli-release": "^0.2.9",
"ember-cli-sri": "^2.1.0",
Expand Down
Binary file removed public/pointer.png
Binary file not shown.

0 comments on commit a82f031

Please sign in to comment.