Use blocked scoped variables
In addition to using const and let, this also upgrades our linter config and removes lint (mostly whitespace).
This commit is contained in:
@@ -5,18 +5,18 @@ import TileLayer from '../src/ol/layer/Tile.js';
|
||||
import {fromLonLat} from '../src/ol/proj.js';
|
||||
import OSM from '../src/ol/source/OSM.js';
|
||||
|
||||
var london = fromLonLat([-0.12755, 51.507222]);
|
||||
var moscow = fromLonLat([37.6178, 55.7517]);
|
||||
var istanbul = fromLonLat([28.9744, 41.0128]);
|
||||
var rome = fromLonLat([12.5, 41.9]);
|
||||
var bern = fromLonLat([7.4458, 46.95]);
|
||||
const london = fromLonLat([-0.12755, 51.507222]);
|
||||
const moscow = fromLonLat([37.6178, 55.7517]);
|
||||
const istanbul = fromLonLat([28.9744, 41.0128]);
|
||||
const rome = fromLonLat([12.5, 41.9]);
|
||||
const bern = fromLonLat([7.4458, 46.95]);
|
||||
|
||||
var view = new View({
|
||||
const view = new View({
|
||||
center: istanbul,
|
||||
zoom: 6
|
||||
});
|
||||
|
||||
var map = new Map({
|
||||
const map = new Map({
|
||||
target: 'map',
|
||||
layers: [
|
||||
new TileLayer({
|
||||
@@ -32,7 +32,9 @@ var map = new Map({
|
||||
|
||||
// A bounce easing method (from https://github.com/DmitryBaranovskiy/raphael).
|
||||
function bounce(t) {
|
||||
var s = 7.5625, p = 2.75, l;
|
||||
const s = 7.5625;
|
||||
const p = 2.75;
|
||||
let l;
|
||||
if (t < (1 / p)) {
|
||||
l = s * t * t;
|
||||
} else {
|
||||
@@ -75,7 +77,7 @@ onClick('rotate-right', function() {
|
||||
|
||||
onClick('rotate-around-rome', function() {
|
||||
// Rotation animation takes the shortest arc, so animate in two parts
|
||||
var rotation = view.getRotation();
|
||||
const rotation = view.getRotation();
|
||||
view.animate({
|
||||
rotation: rotation + Math.PI,
|
||||
anchor: rome,
|
||||
@@ -112,7 +114,7 @@ onClick('bounce-to-istanbul', function() {
|
||||
|
||||
onClick('spin-to-rome', function() {
|
||||
// Rotation animation takes the shortest arc, so animate in two parts
|
||||
var center = view.getCenter();
|
||||
const center = view.getCenter();
|
||||
view.animate({
|
||||
center: [
|
||||
center[0] + (rome[0] - center[0]) / 2,
|
||||
@@ -128,10 +130,10 @@ onClick('spin-to-rome', function() {
|
||||
});
|
||||
|
||||
function flyTo(location, done) {
|
||||
var duration = 2000;
|
||||
var zoom = view.getZoom();
|
||||
var parts = 2;
|
||||
var called = false;
|
||||
const duration = 2000;
|
||||
const zoom = view.getZoom();
|
||||
let parts = 2;
|
||||
let called = false;
|
||||
function callback(complete) {
|
||||
--parts;
|
||||
if (called) {
|
||||
@@ -160,13 +162,13 @@ onClick('fly-to-bern', function() {
|
||||
});
|
||||
|
||||
function tour() {
|
||||
var locations = [london, bern, rome, moscow, istanbul];
|
||||
var index = -1;
|
||||
const locations = [london, bern, rome, moscow, istanbul];
|
||||
let index = -1;
|
||||
function next(more) {
|
||||
if (more) {
|
||||
++index;
|
||||
if (index < locations.length) {
|
||||
var delay = index === 0 ? 0 : 750;
|
||||
const delay = index === 0 ? 0 : 750;
|
||||
setTimeout(function() {
|
||||
flyTo(locations[index], next);
|
||||
}, delay);
|
||||
|
||||
Reference in New Issue
Block a user