You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 28, 2020. It is now read-only.
After making a programmatic change to a hidden candlestick element, the toggle seems to be incorrectly positioned when the candlestick element is made visible.
This seems to affect the on and default settings, off seems ok. When setting the hidden candlestick to on, the toggle ends up just outside the background to the far left of the element. When setting to default, the toggle ends up in a similar position, just to the left of where it would normally be in the off position.
Steps to reproduce: Given the following basic test case:
If $('#candlestick1').candlestick('on') or $('#candlestick1').candlestick('default') is called again once the element is visible, the toggle returns to the correct position for the specified setting.
Thanks.
The text was updated successfully, but these errors were encountered:
It looks like the cause of this issue is the change to theouterWidth of the div.candlestick-bg when the candlestick is hidden, resulting in the calculated position of the toggle being incorrect.
Maybe there's a better approach but I've added a function that calculates the outerWidth of a hidden div.candlestick-bg element:
/**
* Get the element bg width for a candlestick element that may be hidden
*
* @param $candlestickBg a jquery object for a div.candlestick-bg element
*/
function _getBgWidth($candlestickBg) {
// If the node is already visible, return the outerWidth
if($candlestickBg.is(':visible')) {
return $candlestickBg.outerWidth();
}
// If the node is hidden, its necessary to clone the element and
// add the clone to the DOM with visibility: hidden set to get the
// actual element width when its not visible.
var $clonedEl = $candlestickBg.parent().clone().css('visibility', 'hidden');
$('body').append($clonedEl);
var outerWidth = $clonedEl.find('.candlestick-bg').outerWidth();
return outerWidth;
}
This is then called as _getBgWidth(this.parent) in place of this.parent.outerWidth() at:
This seems to solve the problem for my use case. If this is a sufficiently general issue to warrant a fix and the approach described above seems reasonable, I can raise a PR.
jcohen02
added a commit
to jcohen02/candlestick
that referenced
this issue
Oct 25, 2017
After making a programmatic change to a hidden candlestick element, the toggle seems to be incorrectly positioned when the candlestick element is made visible.
This seems to affect the
on
anddefault
settings,off
seems ok. When setting the hidden candlestick to on, the toggle ends up just outside the background to the far left of the element. When setting to default, the toggle ends up in a similar position, just to the left of where it would normally be in the off position.Steps to reproduce: Given the following basic test case:
Running the following (in the browser console) will demonstrate the issue:
If
$('#candlestick1').candlestick('on')
or$('#candlestick1').candlestick('default')
is called again once the element is visible, the toggle returns to the correct position for the specified setting.Thanks.
The text was updated successfully, but these errors were encountered: