mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 10:07:19 +00:00
Use Date.now() instead of new Date()
Just for when what we actually want is a millisecond counter. Interesting video about this: https://www.youtube.com/watch?v=Vo72W1HWeFI
This commit is contained in:
parent
22a529b28d
commit
e366aa3746
@ -267,7 +267,7 @@ Synchronise a set of changes to the server
|
||||
*/
|
||||
Syncer.prototype.syncToServer = function(changes) {
|
||||
var self = this,
|
||||
now = new Date(),
|
||||
now = Date.now(),
|
||||
filteredChanges = this.filterFn.call(this.wiki,function(callback) {
|
||||
$tw.utils.each(changes,function(change,title) {
|
||||
var tiddler = self.wiki.getTiddler(title);
|
||||
@ -371,7 +371,7 @@ Queue up a sync task. If there is already a pending task for the tiddler, just u
|
||||
*/
|
||||
Syncer.prototype.enqueueSyncTask = function(task) {
|
||||
var self = this,
|
||||
now = new Date();
|
||||
now = Date.now();
|
||||
// Set the timestamps on this task
|
||||
task.queueTime = now;
|
||||
task.lastModificationTime = now;
|
||||
@ -474,7 +474,7 @@ Choose the next applicable task
|
||||
Syncer.prototype.chooseNextTask = function() {
|
||||
var self = this,
|
||||
candidateTask = null,
|
||||
now = new Date();
|
||||
now = Date.now();
|
||||
// Select the best candidate task
|
||||
$tw.utils.each(this.taskQueue,function(task,title) {
|
||||
// Exclude the task if there's one of the same name in progress
|
||||
|
@ -57,7 +57,7 @@ PageScroller.prototype.scrollIntoView = function(element) {
|
||||
var duration = $tw.utils.getAnimationDuration();
|
||||
// Now get ready to scroll the body
|
||||
this.cancelScroll();
|
||||
this.startTime = new Date();
|
||||
this.startTime = Date.now();
|
||||
var scrollPosition = $tw.utils.getScrollPosition();
|
||||
// Get the client bounds of the element and adjust by the scroll position
|
||||
var clientBounds = element.getBoundingClientRect(),
|
||||
@ -94,7 +94,7 @@ PageScroller.prototype.scrollIntoView = function(element) {
|
||||
if(duration <= 0) {
|
||||
t = 1;
|
||||
} else {
|
||||
t = ((new Date()) - self.startTime) / duration;
|
||||
t = ((Date.now()) - self.startTime) / duration;
|
||||
}
|
||||
if(t >= 1) {
|
||||
self.cancelScroll();
|
||||
|
@ -475,7 +475,7 @@ exports.timer = function(base) {
|
||||
} else if(window.performance) {
|
||||
m = performance.now();
|
||||
} else {
|
||||
m = new Date();
|
||||
m = Date.now();
|
||||
}
|
||||
if(typeof base !== "undefined") {
|
||||
m = m - base;
|
||||
|
@ -68,7 +68,7 @@ Scroll an element into view
|
||||
ScrollableWidget.prototype.scrollIntoView = function(element) {
|
||||
var duration = $tw.utils.getAnimationDuration();
|
||||
this.cancelScroll();
|
||||
this.startTime = new Date();
|
||||
this.startTime = Date.now();
|
||||
var scrollPosition = {
|
||||
x: this.outerDomNode.scrollLeft,
|
||||
y: this.outerDomNode.scrollTop
|
||||
@ -112,7 +112,7 @@ ScrollableWidget.prototype.scrollIntoView = function(element) {
|
||||
if(duration <= 0) {
|
||||
t = 1;
|
||||
} else {
|
||||
t = ((new Date()) - self.startTime) / duration;
|
||||
t = ((Date.now()) - self.startTime) / duration;
|
||||
}
|
||||
if(t >= 1) {
|
||||
self.cancelScroll();
|
||||
|
Loading…
Reference in New Issue
Block a user