Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix performance issue on new theme #1216

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion js/controller/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ angular.module('listenone').controller('NavigationController', [

$scope.addLocalMusic = (list_id) => {
if (isElectron()) {
const { remote } = require('electron');
const remote = require('@electron/remote');
const remoteFunctions = remote.require('./functions.js');
remote.dialog
.showOpenDialog({
Expand Down
2 changes: 1 addition & 1 deletion js/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function github() {
const url = `${OAUTH_URL}/authorize?client_id=${client_id}&scope=gist`;
if (isElectron()) {
// normal window for link
const { BrowserWindow } = require('electron').remote; // eslint-disable-line import/no-unresolved
const { BrowserWindow } = require('@electron/remote'); // eslint-disable-line import/no-unresolved
let win = new BrowserWindow({
width: 1000,
height: 670,
Expand Down
22 changes: 11 additions & 11 deletions js/lowebutil.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, '\\$&');
name = name.replace(/[[\]]/g, '\\$&');
const regex = new RegExp(`[?&]${name}(=([^&#]*)|&|#|$)`);

const results = regex.exec(url);
Expand Down Expand Up @@ -67,7 +67,7 @@ function setPrototypeOfLocalStorage() {
try {
return value && JSON.parse(value);
} catch (error) {
return {}
return {};
}
};
proto.setObject = function setObject(key, value) {
Expand Down Expand Up @@ -97,19 +97,19 @@ function easeInOutQuad(t, b, c, d) {
}

function smoothScrollTo(element, to, duration) {
/* https://gist.github.com/andjosh/6764939 */
const start = element.scrollTop;
const change = to - start;
let currentTime = 0;
const increment = 20;
const startTime = performance.now();

const animateScroll = () => {
currentTime += increment;
const val = easeInOutQuad(currentTime, start, change, duration);
const animateScroll = (currentTime) => {
const timeElapsed = currentTime - startTime;
const val = easeInOutQuad(timeElapsed, start, change, duration);
element.scrollTop = val;
if (currentTime < duration) {
setTimeout(animateScroll, increment);
if (timeElapsed < duration) {
requestAnimationFrame(animateScroll);
} else {
element.scrollTop = to; // Ensure it ends exactly at 'to'
}
};
animateScroll();
requestAnimationFrame(animateScroll);
}