-
-
Notifications
You must be signed in to change notification settings - Fork 333
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fdc5432
commit 81c4acd
Showing
21 changed files
with
613 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import Ember from 'ember'; | ||
const { Component, computed, String: { htmlSafe } } = Ember; | ||
|
||
function getElementIndex(node) { | ||
let index = 0; | ||
while ((node = node.previousElementSibling)) { | ||
index++; | ||
} | ||
|
||
return index; | ||
} | ||
|
||
export default Component.extend({ | ||
classNames: ['md-fab-action-item'], | ||
attributeBindings: ['style'], | ||
|
||
style: computed('elementDidRender', 'speedDial.animation', 'speedDial.open', 'speedDial.direction', function() { | ||
if (!this.get('elementDidRender')) { | ||
return; | ||
} | ||
|
||
let animation = this.get('speedDial.animation'); | ||
let open = this.get('speedDial.open'); | ||
if (animation === 'fling') { | ||
if (!open) { | ||
return this.flingClosed(); | ||
} | ||
} else if (animation === 'scale') { | ||
return this.scaleClosed(); | ||
} | ||
}), | ||
|
||
didRender() { | ||
this._super(...arguments); | ||
this.set('elementDidRender', true); | ||
}, | ||
|
||
scaleClosed() { | ||
let items = this.get('speedDial.element').querySelectorAll('.md-fab-action-item'); | ||
let open = this.get('speedDial.open'); | ||
let index = getElementIndex(this.element); | ||
let delay = 65; | ||
let offsetDelay = index * delay; | ||
let startZIndex = 0; | ||
|
||
let opacity = open ? 1 : 0; | ||
let transform = open ? 'scale(1)' : 'scale(0)'; | ||
let transitionDelay = `${open ? offsetDelay : items.length - offsetDelay}ms`; | ||
|
||
// Make the items closest to the trigger have the highest z-index | ||
let zIndex = (items.length - index) + startZIndex; | ||
|
||
return htmlSafe(`opacity: ${opacity}; transform: ${transform}; transition-delay: ${transitionDelay}; z-index: ${zIndex};`); | ||
}, | ||
|
||
flingClosed() { | ||
let triggerElement = this.get('speedDial.element').querySelector('md-fab-trigger'); | ||
let direction = this.get('speedDial.direction'); | ||
let index = getElementIndex(this.element); | ||
|
||
// Make sure to account for differences in the dimensions of the trigger verses the items | ||
// so that we can properly center everything; this helps hide the el's shadows behind | ||
// the trigger. | ||
let triggerItemHeightOffset = (triggerElement.clientHeight - this.element.clientHeight) / 2; | ||
let triggerItemWidthOffset = (triggerElement.clientWidth - this.element.clientWidth) / 2; | ||
|
||
let newPosition, axis; | ||
|
||
switch (direction) { | ||
case 'up': | ||
newPosition = (this.element.scrollHeight * (index + 1) + triggerItemHeightOffset); | ||
axis = 'Y'; | ||
break; | ||
case 'down': | ||
newPosition = -(this.element.scrollHeight * (index + 1) + triggerItemHeightOffset); | ||
axis = 'Y'; | ||
break; | ||
case 'left': | ||
newPosition = (this.element.scrollWidth * (index + 1) + triggerItemWidthOffset); | ||
axis = 'X'; | ||
break; | ||
case 'right': | ||
newPosition = -(this.element.scrollWidth * (index + 1) + triggerItemWidthOffset); | ||
axis = 'X'; | ||
break; | ||
} | ||
|
||
return htmlSafe(`transform: translate${axis}(${newPosition}px)`); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import Ember from 'ember'; | ||
import layout from '../templates/components/paper-speed-dial-actions'; | ||
const { Component } = Ember; | ||
|
||
export default Component.extend({ | ||
layout, | ||
tagName: 'md-fab-actions' | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import Ember from 'ember'; | ||
const { Component } = Ember; | ||
|
||
export default Component.extend({ | ||
tagName: 'md-fab-trigger', | ||
|
||
click() { | ||
this.get('speedDial').toggle(); | ||
}, | ||
|
||
focusOut() { | ||
this.get('speedDial').close(); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import Ember from 'ember'; | ||
import layout from '../templates/components/paper-speed-dial'; | ||
const { Component, computed, run } = Ember; | ||
|
||
export default Component.extend({ | ||
layout, | ||
tagName: 'md-fab-speed-dial', | ||
|
||
classNameBindings: [ | ||
'directionClass', 'open:md-is-open', 'animationClass', | ||
'shouldHideActions:md-animations-waiting', 'hoverFull:md-hover-full' | ||
], | ||
|
||
open: false, | ||
|
||
animation: 'fling', | ||
animationClass: computed('animation', function() { | ||
return `md-${this.get('animation')}`; | ||
}), | ||
|
||
direction: 'down', | ||
directionClass: computed('direction', function() { | ||
return `md-${this.get('direction')}`; | ||
}), | ||
|
||
shouldHideActions: computed('animation', 'elementDidRender', function() { | ||
return this.get('animation') === 'fling' && !this.get('elementDidRender'); | ||
}), | ||
|
||
didRender() { | ||
this._super(...arguments); | ||
run.next(() => { | ||
if (!this.isDestroyed && !this.isDestroying) { | ||
this.set('elementDidRender', true); | ||
} | ||
}); | ||
}, | ||
|
||
mouseEnter() { | ||
this.sendAction('onMouseEnter'); | ||
}, | ||
|
||
mouseLeave() { | ||
this.sendAction('onMouseLeave'); | ||
}, | ||
|
||
toggle() { | ||
this.changeOpenValue(!this.get('open')); | ||
}, | ||
|
||
close() { | ||
this.changeOpenValue(false); | ||
}, | ||
|
||
changeOpenValue(value) { | ||
// support non DDAU scenario | ||
if (this.get('onToggle')) { | ||
this.sendAction('onToggle', value); | ||
} else { | ||
this.set('open', value); | ||
} | ||
} | ||
}); |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{{yield (hash | ||
action=(component "paper-speed-dial-actions-action" speedDial=speedDial) | ||
)}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{{yield (hash | ||
trigger=(component "paper-speed-dial-trigger" speedDial=this) | ||
actions=(component "paper-speed-dial-actions" speedDial=this) | ||
)}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from 'ember-paper/components/paper-speed-dial-actions-action'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from 'ember-paper/components/paper-speed-dial-actions'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from 'ember-paper/components/paper-speed-dial-trigger'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from 'ember-paper/components/paper-speed-dial'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import Ember from 'ember'; | ||
const { Controller } = Ember; | ||
|
||
export default Controller.extend({ | ||
animation: 'fling', | ||
direction: 'down', | ||
|
||
actions: { | ||
toggle(propName) { | ||
this.toggleProperty(propName); | ||
}, | ||
|
||
dummy() { | ||
|
||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.