Skip to content

Commit

Permalink
Merge pull request #4 from Menesetsu/height-animations
Browse files Browse the repository at this point in the history
Added height calculation. Added animation-delay on groupTitles and op…
  • Loading branch information
dramoturg authored Jun 28, 2017
2 parents 7ce2fbf + 53473fd commit d8d0859
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/js/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ var DropDown = (function(DX) {
'</div>',
'</div>'
].join(''),
hideOnClick: true
hideOnClick: true,
animationStepDelay: 0.03
};

/**
Expand Down Expand Up @@ -91,6 +92,21 @@ var DropDown = (function(DX) {
}
}

function reCalculateAnimationDelay(block, config) {
var listChildren = block.querySelectorAll(`.${CN_OPTION}, .${CN_GROUP_TITLE}`);

for(var i=0; i<listChildren.length; i++) {
listChildren[i].style.animationDelay = config.animationStepDelay * i + 's';
}
}

function reCalculateHeight(block) {
block.style.display = 'block';
var dropDownHeight = DX.Measure.getSize(block, true).height;
block.style.display = '';
block.style.height = dropDownHeight + 'px';
}

function getOptionListHTML(data, config) {
return data.reduce(function(prevValue, item) {
var result = '';
Expand Down Expand Up @@ -259,6 +275,8 @@ var DropDown = (function(DX) {
if (!isShownOnce) {
isShownOnce = true;
reCalculateWidth(block, control, config);
reCalculateAnimationDelay(block, config);
reCalculateHeight(block);
}

setHoveredIndex(0);
Expand Down

0 comments on commit d8d0859

Please sign in to comment.