Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
node_modules
.DS_Store
bower_components
package-lock.json
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ module.exports = function(grunt) {
},
dist: {
files: {
'build/spectrum-min.js': ['spectrum.js']
'build/spectrum.min.js': ['spectrum.js']
}
}
}
Expand Down
1 change: 1 addition & 0 deletions build/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
spectrum-min.js
spectrum.min.js
14 changes: 10 additions & 4 deletions spectrum.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@
palette: [["#ffffff", "#000000", "#ff0000", "#ff8000", "#ffff00", "#008000", "#0000ff", "#4b0082", "#9400d3"]],
selectionPalette: [],
disabled: false,
offset: null
offset: null,
keepAlpha: false
},
spectrums = [],
IE = !!/msie/i.exec( window.navigator.userAgent ),
Expand Down Expand Up @@ -437,7 +438,7 @@
}, dragStart, dragStop);

if (!!initialColor) {
set(initialColor);
set(initialColor, false, true);

// In case color was black - update the preview UI and set the format
// since the set function will not run (default color is black).
Expand Down Expand Up @@ -688,7 +689,7 @@
updateOriginalInput(true);
}

function set(color, ignoreFormatChange) {
function set(color, ignoreFormatChange, initialColor) {
if (tinycolor.equals(color, get())) {
// Update UI just in case a validation error needs
// to be cleared.
Expand All @@ -707,7 +708,12 @@
currentHue = (newHsv.h % 360) / 360;
currentSaturation = newHsv.s;
currentValue = newHsv.v;
currentAlpha = newHsv.a;

if(initialColor){
currentAlpha = newHsv.a;
}else if(!opts.keepAlpha) {
currentAlpha = newHsv.a;
}
}
updateUI();

Expand Down