mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-06-22 08:24:06 +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) {
|
Syncer.prototype.syncToServer = function(changes) {
|
||||||
var self = this,
|
var self = this,
|
||||||
now = new Date(),
|
now = Date.now(),
|
||||||
filteredChanges = this.filterFn.call(this.wiki,function(callback) {
|
filteredChanges = this.filterFn.call(this.wiki,function(callback) {
|
||||||
$tw.utils.each(changes,function(change,title) {
|
$tw.utils.each(changes,function(change,title) {
|
||||||
var tiddler = self.wiki.getTiddler(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) {
|
Syncer.prototype.enqueueSyncTask = function(task) {
|
||||||
var self = this,
|
var self = this,
|
||||||
now = new Date();
|
now = Date.now();
|
||||||
// Set the timestamps on this task
|
// Set the timestamps on this task
|
||||||
task.queueTime = now;
|
task.queueTime = now;
|
||||||
task.lastModificationTime = now;
|
task.lastModificationTime = now;
|
||||||
@ -474,7 +474,7 @@ Choose the next applicable task
|
|||||||
Syncer.prototype.chooseNextTask = function() {
|
Syncer.prototype.chooseNextTask = function() {
|
||||||
var self = this,
|
var self = this,
|
||||||
candidateTask = null,
|
candidateTask = null,
|
||||||
now = new Date();
|
now = Date.now();
|
||||||
// Select the best candidate task
|
// Select the best candidate task
|
||||||
$tw.utils.each(this.taskQueue,function(task,title) {
|
$tw.utils.each(this.taskQueue,function(task,title) {
|
||||||
// Exclude the task if there's one of the same name in progress
|
// 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();
|
var duration = $tw.utils.getAnimationDuration();
|
||||||
// Now get ready to scroll the body
|
// Now get ready to scroll the body
|
||||||
this.cancelScroll();
|
this.cancelScroll();
|
||||||
this.startTime = new Date();
|
this.startTime = Date.now();
|
||||||
var scrollPosition = $tw.utils.getScrollPosition();
|
var scrollPosition = $tw.utils.getScrollPosition();
|
||||||
// Get the client bounds of the element and adjust by the scroll position
|
// Get the client bounds of the element and adjust by the scroll position
|
||||||
var clientBounds = element.getBoundingClientRect(),
|
var clientBounds = element.getBoundingClientRect(),
|
||||||
@ -94,7 +94,7 @@ PageScroller.prototype.scrollIntoView = function(element) {
|
|||||||
if(duration <= 0) {
|
if(duration <= 0) {
|
||||||
t = 1;
|
t = 1;
|
||||||
} else {
|
} else {
|
||||||
t = ((new Date()) - self.startTime) / duration;
|
t = ((Date.now()) - self.startTime) / duration;
|
||||||
}
|
}
|
||||||
if(t >= 1) {
|
if(t >= 1) {
|
||||||
self.cancelScroll();
|
self.cancelScroll();
|
||||||
|
@ -475,7 +475,7 @@ exports.timer = function(base) {
|
|||||||
} else if(window.performance) {
|
} else if(window.performance) {
|
||||||
m = performance.now();
|
m = performance.now();
|
||||||
} else {
|
} else {
|
||||||
m = new Date();
|
m = Date.now();
|
||||||
}
|
}
|
||||||
if(typeof base !== "undefined") {
|
if(typeof base !== "undefined") {
|
||||||
m = m - base;
|
m = m - base;
|
||||||
|
@ -68,7 +68,7 @@ Scroll an element into view
|
|||||||
ScrollableWidget.prototype.scrollIntoView = function(element) {
|
ScrollableWidget.prototype.scrollIntoView = function(element) {
|
||||||
var duration = $tw.utils.getAnimationDuration();
|
var duration = $tw.utils.getAnimationDuration();
|
||||||
this.cancelScroll();
|
this.cancelScroll();
|
||||||
this.startTime = new Date();
|
this.startTime = Date.now();
|
||||||
var scrollPosition = {
|
var scrollPosition = {
|
||||||
x: this.outerDomNode.scrollLeft,
|
x: this.outerDomNode.scrollLeft,
|
||||||
y: this.outerDomNode.scrollTop
|
y: this.outerDomNode.scrollTop
|
||||||
@ -112,7 +112,7 @@ ScrollableWidget.prototype.scrollIntoView = function(element) {
|
|||||||
if(duration <= 0) {
|
if(duration <= 0) {
|
||||||
t = 1;
|
t = 1;
|
||||||
} else {
|
} else {
|
||||||
t = ((new Date()) - self.startTime) / duration;
|
t = ((Date.now()) - self.startTime) / duration;
|
||||||
}
|
}
|
||||||
if(t >= 1) {
|
if(t >= 1) {
|
||||||
self.cancelScroll();
|
self.cancelScroll();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user