Skip to content

Instantly share code, notes, and snippets.

@ryana
Created August 27, 2014 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryana/23e00d7d8511da2200a4 to your computer and use it in GitHub Desktop.
Save ryana/23e00d7d8511da2200a4 to your computer and use it in GitHub Desktop.
Pretty spotlighting for shepherd.js
Shepherd.on 'show', (o) ->
el = $(o.step.options.attachTo.element).first()
width = el.outerWidth() + 10
height = el.outerHeight() + 10
offset = el.offset()
$('.shep-overlay').show().css({
position: 'absolute',
width: width,
height: height,
'box-shadow': '0px 0px 4px 4px rgba(0,0,0,0.5) inset, 0px 0px 0px 10000px rgba(0,0,0,0.5)',
top: offset.top - 5,
left: offset.left - 5,
'z-index': 1000000
})
Shepherd.on 'inactive', ->
$('.shep-overlay').hide()
$ ->
if $('.shep-overlay').length == 0
shep_el = $('<div class="shep-overlay"></div>')
$('body').append(shep_el)
.shepherd-content {
max-width: 350px;
z-index: 1000000;
}
@ryana
Copy link
Author

ryana commented Aug 27, 2014

Requires jQuery & Shep to be required beforehand. Probably needs prefixed box-shadow rules for all the browsers....

@tamvm
Copy link

tamvm commented Dec 28, 2014

Thanks, it's pretty useful, however, I need to modify small thing to make it work:
el = $(o.step.options.attachTo.split(" ")[0]).first()

@Adrian10988
Copy link

I'm not too keen on js. Where do you put this code? Just tried pasting it into my initialization code but it's throwing all types of errors. Does it have to go inside the shepherd.js file?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment