Skip to content

Commit 62a615e

Browse files
author
Marcus McCurdy
committed
Adds targeting by querySelector
1 parent 1b9940d commit 62a615e

3 files changed

Lines changed: 16 additions & 11 deletions

File tree

pace.coffee

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ defaultOptions =
4141
# how many samples we need before we consider a low number to mean completion.
4242
minSamples: 10
4343

44+
target: 'body'
45+
4446
now = ->
4547
performance?.now?() ? +new Date
4648

@@ -115,11 +117,11 @@ class Bar
115117
</div>
116118
<div class="pace-activity"></div>
117119
'''
118-
119-
if document.body.firstChild?
120-
document.body.insertBefore @el, document.body.firstChild
120+
targetElement = document.querySelector(options.target);
121+
if targetElement.firstChild?
122+
targetElement.insertBefore @el, targetElement.firstChild
121123
else
122-
document.body.appendChild @el
124+
targetElement.appendChild @el
123125

124126
@el
125127

@@ -140,7 +142,7 @@ class Bar
140142
@el = undefined
141143

142144
render: ->
143-
if not document.body?
145+
if not document.querySelector(options.target)?
144146
return false
145147

146148
el = @getElement()

pace.js

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

pace.min.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)