Skip to content

Commit e4ae0bc

Browse files
authored
Merge pull request #99 from maxloginov/master
Added some new refresh() logic
2 parents 087a497 + a4ad1dc commit e4ae0bc

File tree

7 files changed

+69
-48
lines changed

7 files changed

+69
-48
lines changed

README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@ change `body` to some other selector.
5656
$('.container').chardinJs('start')
5757
```
5858

59+
You may also refresh instructions overlay any time to reflect whatever changes happened to the underlying page elements since the instructions overlay has been displayed.
60+
61+
```Javascript
62+
var chardinOverlay = $('body').chardinJs('start');
63+
...
64+
chardinOverlay.refresh();
65+
```
66+
5967
## Methods
6068

6169
### .chardinJs('start')
@@ -92,6 +100,7 @@ Triggered when chardinJs is stopped.
92100
* [Maxim Syabro](https://github.com/syabro)
93101
* [nmeum](https://github.com/nmeum)
94102
* [printercu](https://github.com/printercu)
103+
* [Max Loginov](https://github.com/maxloginov)
95104

96105
## Contributions
97106

@@ -121,7 +130,3 @@ limitations under the License.
121130
[0]: https://github.com/heelhook/chardin.js/blob/master/chardinjs.css
122131
[1]: https://github.com/heelhook/chardin.js/blob/master/chardinjs.min.js
123132
[2]: https://github.com/heelhook
124-
125-
126-
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/heelhook/chardin.js/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
127-

chardinjs.coffee

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ do ($ = window.jQuery, window) ->
2020

2121
refresh: ()->
2222
if @._overlay_visible()
23-
@._position_helper_layer(el) for el in @$el.find('*[data-intro]:visible')
23+
@._position_helper_layer(el) for el in @$el.find('*[data-intro]')
2424
else
2525
return this
2626

@@ -32,6 +32,8 @@ do ($ = window.jQuery, window) ->
3232
@$el.find('.chardinjs-show-element').removeClass('chardinjs-show-element')
3333
@$el.find('.chardinjs-relative-position').removeClass('chardinjs-relative-position')
3434

35+
$(el).data('helper_layer', null).data('tooltip_layer',null) for el in @$el.find('*[data-intro]')
36+
3537
if window.removeEventListener
3638
window.removeEventListener "keydown", @_onKeyDown, true
3739
#IE
@@ -100,7 +102,15 @@ do ($ = window.jQuery, window) ->
100102
_position_helper_layer: (element) ->
101103
helper_layer = $(element).data('helper_layer')
102104
element_position = @._get_offset(element)
103-
helper_layer.setAttribute "style", "width: #{element_position.width}px; height:#{element_position.height}px; top:#{element_position.top}px; left: #{element_position.left}px;"
105+
if $(element).is(':visible') and helper_layer
106+
# element is VISIBLE, helper_layer EXISTS
107+
helper_layer.setAttribute "style", "display: block; width: #{element_position.width}px; height:#{element_position.height}px; top:#{element_position.top}px; left: #{element_position.left}px;"
108+
if $(element).is(':visible') and !helper_layer
109+
# element is INVISIBLE, helper_layer is NULL
110+
@._show_element element
111+
if !$(element).is(':visible') and helper_layer
112+
# element is INVISIBLE, helper_layer EXISTS
113+
helper_layer.setAttribute "style", "display: none; width: #{element_position.width}px; height:#{element_position.height}px; top:#{element_position.top}px; left: #{element_position.left}px;"
104114

105115
_show_element: (element) ->
106116
element_position = @._get_offset(element)

chardinjs.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
transition: all 0.3s ease-out; }
2121
.chardinjs-helper-layer.chardinjs-left {
2222
border-left: solid white 1px;
23-
margin-left: -10px; }
23+
padding-left: 10px; }
2424
.chardinjs-helper-layer.chardinjs-right {
2525
border-right: solid white 1px;
2626
padding-right: 10px; }

chardinjs.js

Lines changed: 43 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chardinjs.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chardinjs.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
color: white;
2121
@include transition(all 0.3s ease-out);
2222

23-
&.chardinjs-left { border-left: solid white 1px; margin-left: -10px; }
23+
&.chardinjs-left { border-left: solid white 1px; padding-left: 10px; }
2424
&.chardinjs-right { border-right: solid white 1px; padding-right: 10px; }
2525
&.chardinjs-bottom { border-bottom: solid white 1px; padding-bottom: 10px; }
2626
&.chardinjs-top { border-top: solid white 1px; padding-top: 10px; }

example/js/demo.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)