Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions addon/mixins/col-pick.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default Ember.Mixin.create( {
if (this.get('useHashtag')) {
hex = '#' + hex;
}

this.set('previewValue', hex);

if (this._isValidPreviewValue()) {
Expand All @@ -67,6 +67,25 @@ export default Ember.Mixin.create( {
}),
onHide: Ember.run.bind(this, function(){
this.sendAction('onHide');
}),
onShow: Ember.run.bind(this, function(el) {
// Change the position of the colorpicker based on the window height
let winHeight = this.$(window).outerHeight();
let inputField = this.$();
let inputFieldPosition = inputField.offset();
let inputFieldHeight = inputField.outerHeight();
let colorPickerElem = this.$(el);
let colorPickerHeight = colorPickerElem.outerHeight();
let colorPickerTop = 0;

if (winHeight < (inputFieldPosition.top + inputFieldHeight + colorPickerHeight)) {
colorPickerTop = inputFieldPosition.top - colorPickerHeight;
} else {
colorPickerTop = inputFieldPosition.top + inputFieldHeight;
}
colorPickerElem.css({
'top': colorPickerTop + 'px'
});
})
});

Expand Down Expand Up @@ -113,4 +132,3 @@ export default Ember.Mixin.create( {
this._super();
}
});