Skip to content

Commit

Permalink
spare cycles
Browse files Browse the repository at this point in the history
  • Loading branch information
bevacqua committed Mar 21, 2015
1 parent 7bfcf98 commit dcaaa6b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
11 changes: 9 additions & 2 deletions bullseye.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ function bullseye (el, target, options) {
var o = options || {};
var destroyed = false;
var throttledPosition = throttle(position, 30);
var tailor = o.caret && tailormade(target, { update: update, positions: ['start'] });
var tailorOptions = { update: update, positions: ['start'] };
var tailor = o.caret && tailormade(target, tailorOptions);

position();

Expand All @@ -18,9 +19,14 @@ function bullseye (el, target, options) {

return {
refresh: position,
destroy: destroy
destroy: destroy,
sleep: sleep
};

function sleep () {
tailorOptions.sleeping = true;
}

function update (readings) {
position(readings);
}
Expand All @@ -30,6 +36,7 @@ function bullseye (el, target, options) {
throw new Error('Bullseye can\'t refresh after being destroyed. Create another instance instead.');
}
if (tailor && !readings) {
tailorOptions.sleeping = false;
tailor.refresh(); return;
}
var bounds = target.getBoundingClientRect();
Expand Down
2 changes: 1 addition & 1 deletion changelog.markdown
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 1.2.6 Arena Net
# 1.2.7 Arena Net

- Allow `bullseye` to effectively track `<textarea>` elements as well

Expand Down
3 changes: 3 additions & 0 deletions tailormade.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ function tailormade (el, options) {
};

function refresh () {
if (o.sleeping) {
return;
}
var p = sell(el);
var context = prepare();
var readings = {};
Expand Down

0 comments on commit dcaaa6b

Please sign in to comment.