Skip to content

Commit ba7cd43

Browse files
pzuraqChristopher Garrett
authored andcommitted
Version 0.1.0 refactor
1 parent 7fd6005 commit ba7cd43

File tree

96 files changed

+10150
-517
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+10150
-517
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ env:
1818
matrix:
1919
fast_finish: true
2020
allow_failures:
21+
- env: EMBER_TRY_SCENARIO=ember-beta
2122
- env: EMBER_TRY_SCENARIO=ember-canary
2223

2324
before_install:

README.md

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,32 @@
1-
# Liquid-wormhole
1+
# Liquid Tether
22

3-
This README outlines the details of collaborating on this Ember addon.
3+
Liquid Tether combines the ideas behind
4+
[Ember Tether](https://github.com/yapplabs/ember-tether.git) with the power of
5+
[Liquid Fire](http://ef4.github.io/liquid-fire/) to provide an accessible,
6+
easy-to-use toolkit for both positioning & animating UI elements.
47

5-
## Installation
8+
Interactive documentation can be found
9+
[here](http://pzuraq.github.io/liquid-tether/).
610

7-
* `git clone` this repository
8-
* `npm install`
9-
* `bower install`
11+
## Ember Compatibility
1012

11-
## Running
13+
Liquid Tether has only been tested on Ember 1.13. Testing for newer versions of
14+
Ember is on the roadmap. Older versions are not currently on the roadmap.
1215

13-
* `ember server`
14-
* Visit your app at http://localhost:4200.
16+
## Installation
1517

16-
## Running Tests
18+
```
19+
ember install liquid-tether
20+
```
1721

18-
* `ember test`
19-
* `ember test --server`
22+
## Contributing
2023

21-
## Building
24+
Fork the repository, make your changes on a branch, and submit a pull request.
2225

23-
* `ember build`
26+
## Acknowledgments
2427

25-
For more information on using ember-cli, visit [http://www.ember-cli.com/](http://www.ember-cli.com/).
28+
Credits to [@ef4](https://github.com/ef4),
29+
[@chrislopresto](https://github.com/chrislopresto),
30+
[@lukemelia](https://github.com/lukemelia), and
31+
[@zackbloom](https://github.com/zackbloom) for their help in making
32+
this library possible!

addon/.gitkeep

Whitespace-only changes.

addon/components/liquid-append.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,9 @@ export default Ember.Component.extend({
55
const nodes = this.get('nodes');
66

77
this.$().append(nodes);
8+
},
9+
10+
didAnimateTransition() {
11+
this.sendAction('did-animate-transition');
812
}
913
});

addon/components/liquid-target-container.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@ import Ember from 'ember';
22
import layout from '../templates/components/liquid-target-container';
33

44
const { inject } = Ember;
5-
65
const { service } = inject;
76

87
export default Ember.Component.extend({
98
layout: layout,
109
classNames: ['liquid-target-container'],
1110

12-
liquidTargetService: service('liquid-target')
11+
liquidTargetService: service('liquid-target'),
12+
13+
actions: {
14+
removeTarget(target) {
15+
this.get('liquidTargetService').removeTarget(target);
16+
}
17+
}
1318
});

addon/components/liquid-target.js

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,27 @@ import Ember from 'ember';
22
import layout from '../templates/components/liquid-target';
33

44
const { computed, inject } = Ember;
5-
65
const { service } = inject;
76

87
export default Ember.Component.extend({
98
layout: layout,
109
classNames: ['liquid-target'],
1110

12-
liquidTargetService: service('liquid-target'),
11+
liquidTargetService: service('liquidTarget'),
1312

14-
init() {
15-
const name = this.get('name');
13+
currentItem: computed('items.lastObject', function() {
14+
return this.get('items.lastObject') || {};
15+
}),
1616

17-
if (!this.get(`liquidTargetService.targets.${name}`)) {
18-
this.set(`liquidTargetService.targets.${name}`, Ember.A());
17+
cleanup() {
18+
if (this.get('items.length') === 0) {
19+
this.sendAction('on-cleanup', this.get('target'));
1920
}
20-
21-
this._super(...arguments);
2221
},
2322

24-
nodes: computed('liquidTargetService', 'name', function() {
25-
const name = this.get('name');
26-
return this.get(`liquidTargetService.targets.${name}`);
27-
}),
28-
29-
currentNodes: computed('nodes.lastObject', function() {
30-
const index = this.get('nodes.length');
31-
const { nodes } = index ? this.get('nodes.lastObject') : { null };
32-
33-
return { nodes, index };
34-
})
23+
actions: {
24+
didAnimateTransition() {
25+
this.cleanup();
26+
}
27+
}
3528
});

addon/components/liquid-tether.js

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ export default LiquidWormhole.extend({
1111

1212
to: 'liquid-tether',
1313

14-
'class-prefix': 'liquid-tether',
14+
classPrefix: 'liquid-tether',
1515
target: null,
1616
attachment: null,
17-
'target-attachment': null,
17+
targetAttachment: null,
1818
offset: null,
19-
'target-offset': null,
20-
'target-modifier': null,
19+
targetOffset: null,
20+
targetModifier: null,
2121
constraints: null,
2222
optimizations: null,
2323

@@ -27,6 +27,12 @@ export default LiquidWormhole.extend({
2727
this._super();
2828

2929
this.addTether();
30+
31+
run.schedule('render', () => {
32+
if (this._tether) {
33+
this._tether.position();
34+
}
35+
});
3036
},
3137

3238
willDestroyElement() {
@@ -42,13 +48,13 @@ export default LiquidWormhole.extend({
4248
'class-prefix',
4349
'target',
4450
'attachment',
45-
'target-attachment',
51+
'targetAttachment',
4652
'offset',
47-
'target-offset',
48-
'target-modifier',
53+
'targetOffset',
54+
'targetModifier',
4955
'constraints',
5056
'optimizations',
51-
'liquidTargetName',
57+
'liquidTarget',
5258
function() {
5359
this.removeTether(this._tether);
5460
this.addTether();
@@ -81,13 +87,14 @@ export default LiquidWormhole.extend({
8187
let options = {
8288
element: this._tetherElement,
8389
target: get(this, '_tetherTarget'),
90+
moveRoot: false
8491
};
85-
[ 'class-prefix',
92+
[ 'classPrefix',
8693
'attachment',
87-
'target-attachment',
94+
'targetAttachment',
8895
'offset',
89-
'target-offset',
90-
'target-modifier',
96+
'targetOffset',
97+
'targetModifier',
9198
'constraints',
9299
'optimizations'
93100
].forEach((k) => {

addon/components/liquid-wormhole.js

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Ember from 'ember';
22

3-
const { computed, inject, observer, generateGuid } = Ember;
3+
const { computed, inject, observer, on } = Ember;
44

55
const { service } = inject;
66
const { alias } = computed;
@@ -15,28 +15,18 @@ export default Ember.Component.extend({
1515
return this.$().children();
1616
}),
1717

18-
didInsertElement() {
19-
this.appendNodes();
20-
},
21-
22-
willDestroyElement() {
23-
this.removeNodes();
24-
},
25-
2618
liquidTargetDidChange: observer('liquidTarget', function() {
27-
this.removeNodes();
28-
this.appendNodes();
19+
this.removeFromTarget();
20+
this.appendToTarget();
2921
}),
3022

31-
appendNodes() {
32-
const nodes = this.get('nodes');
33-
23+
appendToTarget: on('didInsertElement', function() {
3424
this._target = this.get('liquidTarget');
3525

36-
this.get('liquidTargetService').appendRange(this, this._target, nodes);
37-
},
26+
this.get('liquidTargetService').appendItem(this._target, this);
27+
}),
3828

39-
removeNodes() {
40-
this.get('liquidTargetService').removeRange(this, this._target);
41-
}
29+
removeFromTarget: on('willDestroyElement', function() {
30+
this.get('liquidTargetService').removeItem(this._target, this);
31+
})
4232
});

addon/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Constraint from 'liquid-fire/constraint';
2+
3+
export function target(name) {
4+
return new Constraint('parentElementClass', `${name}-liquid-target`);
5+
}

addon/initializers/liquid-target-container.js

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)