Skip to content

Commit 8a2cd12

Browse files
committed
Merge branch 'release/1.6.4'
2 parents c67e751 + 9d3e421 commit 8a2cd12

File tree

7 files changed

+60
-32
lines changed

7 files changed

+60
-32
lines changed

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# Build: docker build -t docker.smithmicro.io/mapbox-gl-circle:dev .
2-
# Start: docker run -itp 9966:9966 docker.smithmicro.io/mapbox-gl-circle:dev
1+
# Build: docker build -t mapbox-gl-circle:dev .
2+
# Start: docker run -itp 9966:9966 mapbox-gl-circle:dev
33
# Evaluate: open http://localhost:9966
44

55
FROM node:8-alpine

Jenkinsfile

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ pipeline {
3434
return fullBranchName.split('/') as List
3535
}
3636

37-
throw new AssertionError("Enforcing Gitflow Workflow and SemVer. Ha!")
37+
if (fullBranchName.matches(/PR-\d+$/)) {
38+
return fullBranchName.split('-') as List
39+
}
40+
41+
error "Enforcing Gitflow Workflow and SemVer on '${fullBranchName}'. Ha!"
3842
}
3943

4044
def getBuildVersion = { String fullBranchName, buildNumber ->
@@ -55,8 +59,10 @@ pipeline {
5559
case 'release':
5660
assert branchTypeAndName[1] == projectVersion
5761
return "${projectVersion}-rc.${buildNumber}"
62+
case 'PR':
63+
return "${projectVersion}+PR.${branchTypeAndName[1]}.${buildNumber}"
5864
default:
59-
throw new AssertionError("Oops, Mats messed up! :(")
65+
error "Oops, we messed up! :("
6066
}
6167
}
6268

@@ -73,8 +79,6 @@ pipeline {
7379

7480
env.BUILD_VERSION = getBuildVersion(BRANCH_NAME as String, BUILD_NUMBER)
7581
env.NPM_TAG = getNpmTag(BRANCH_NAME as String)
76-
env.DOCKER_TAG = env.BUILD_VERSION.replace('+', '_')
77-
env.DOCKER_TAG_ALIAS = env.NPM_TAG
7882
env.BUILD_TYPE = env.NPM_TAG ? env.NPM_TAG : 'develop' // latest, next or develop
7983

8084
if (env.BUILD_TYPE == 'next') {
@@ -125,27 +129,10 @@ pipeline {
125129
}
126130
environment {
127131
NPM_TOKEN = credentials('mblomdahl_npm')
128-
DOCKER_LOGIN = credentials('docker_smithmicro_io')
129132
}
130133
steps {
131134
//noinspection GroovyAssignabilityCheck
132135
parallel(
133-
'Docker Image': {
134-
dir('_docker-build') {
135-
unstash 'pre_install_git_checkout'
136-
sh 'docker login -u $DOCKER_LOGIN_USR -p $DOCKER_LOGIN_PSW docker.smithmicro.io'
137-
sh 'docker build -t docker.smithmicro.io/mapbox-gl-circle:$DOCKER_TAG .'
138-
sh 'docker save docker.smithmicro.io/mapbox-gl-circle:$DOCKER_TAG | gzip - \
139-
> mapbox-gl-circle-$BUILD_VERSION.docker.tar.gz'
140-
archiveArtifacts "mapbox-gl-circle-${BUILD_VERSION}.docker.tar.gz"
141-
142-
sh 'docker push docker.smithmicro.io/mapbox-gl-circle:$DOCKER_TAG'
143-
sh 'docker tag docker.smithmicro.io/mapbox-gl-circle:$DOCKER_TAG \
144-
docker.smithmicro.io/mapbox-gl-circle:$DOCKER_TAG_ALIAS'
145-
sh 'docker push docker.smithmicro.io/mapbox-gl-circle:$DOCKER_TAG_ALIAS'
146-
deleteDir()
147-
}
148-
},
149136
'NPM Package': {
150137
sh 'echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> .npmrc'
151138
sh 'npm publish --tag $NPM_TAG .'

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,13 @@ Returns **{sw: {lat: [number](https://developer.mozilla.org/en-US/docs/Web/JavaS
186186

187187
## Changelog
188188

189+
### v. 1.6.4
190+
191+
- Performance improvements for Firefox and Edge on slow computers
192+
([#64](https://github.com/smithmicro/mapbox-gl-circle/issues/64),
193+
[#59](https://github.com/smithmicro/mapbox-gl-circle/issues/59))
194+
- Deprecated Docker build step
195+
189196
### v. 1.6.3
190197

191198
- Transferring core project into SmithMicro organization, `mblomdahl/mapbox-gl-circle -> smithmicro/mapbox-gl-circle`

index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no'/>
77
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.40.1/mapbox-gl.js'></script>
88
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.40.1/mapbox-gl.css' rel='stylesheet'/>
9-
<script src='https://npmcdn.com/@turf/turf/turf.min.js'></script>
9+
<script src='https://npmcdn.com/@turf/turf@4.7.3/turf.min.js'></script>
1010
<script src='dist/mapbox-gl-circle.min.js'></script>
1111
<script src='https://npmcdn.com/mapbox-gl-circle/dist/mapbox-gl-circle.min.js'></script>
1212
<style>
@@ -92,8 +92,8 @@
9292
mapboxgl.accessToken = 'pk.eyJ1IjoiYW5hbmR0aGFra2VyIiwiYSI6ImNqNWptdjU1YjJheWszM256ZWN0MXNrejMifQ.TXnoKtnlam-KBmRSjXQgEw';
9393

9494
function boundsTo5percentRadius(bounds) {
95-
// noinspection JSCheckFunctionSignatures
9695
// noinspection JSUnresolvedVariable
96+
// noinspection JSCheckFunctionSignatures
9797
return Math.round(
9898
turf.distance(bounds.getSouthWest().toArray(), bounds.getNorthEast().toArray(), 'meters') * .05);
9999
}

lib/main.js

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,8 @@ class MapboxCircle {
239239
/** @const {Array<Point>} */ this._handles = undefined;
240240
/** @const {boolean} */ this._centerDragActive = false;
241241
/** @const {boolean} */ this._radiusDragActive = false;
242+
/** @const {Object} */ this._debouncedHandlers = {};
243+
/** @const {number} */ this._updateCount = 0;
242244

243245
[ // Bind all event handlers.
244246
'_onZoomEnd',
@@ -282,6 +284,36 @@ class MapboxCircle {
282284
return window.navigator.userAgent.indexOf('Chrome') === -1 && window.navigator.userAgent.indexOf('Safari') > -1;
283285
}
284286

287+
/**
288+
* Add debounced event handler to map.
289+
* @param {string} event Mapbox GL event name
290+
* @param {Function} handler Event handler
291+
* @private
292+
*/
293+
_mapOnDebounced(event, handler) {
294+
let ticking = false;
295+
this._debouncedHandlers[handler] = (args) => {
296+
if (!ticking) {
297+
requestAnimationFrame(() => {
298+
handler(args);
299+
ticking = false;
300+
});
301+
}
302+
ticking = true;
303+
};
304+
this.map.on(event, this._debouncedHandlers[handler]);
305+
}
306+
307+
/**
308+
* Remove debounced event handler from map.
309+
* @param {string} event Mapbox GL event name
310+
* @param {Function} handler Event handler
311+
* @private
312+
*/
313+
_mapOffDebounced(event, handler) {
314+
this.map.off(event, this._debouncedHandlers[handler]);
315+
}
316+
285317
/**
286318
* Re-calculate/update circle polygon and handles.
287319
* @private
@@ -306,9 +338,11 @@ class MapboxCircle {
306338
}
307339

308340
if (this.options.debugEl) {
341+
this._updateCount += 1;
309342
this.options.debugEl.innerHTML = ('Center: ' + JSON.stringify(this.getCenter()) + ' / Radius: ' + radius +
310343
' / Bounds: ' + JSON.stringify(this.getBounds()) + ' / Steps: ' + steps +
311-
' / Zoom: ' + zoom.toFixed(2) + ' / ID: ' + this._instanceId);
344+
' / Zoom: ' + zoom.toFixed(2) + ' / ID: ' + this._instanceId +
345+
' / #: ' + this._updateCount);
312346
}
313347
}
314348

@@ -468,7 +502,7 @@ class MapboxCircle {
468502
*/
469503
_onCenterHandleMouseDown() {
470504
this._centerDragActive = true;
471-
this.map.on('mousemove', this._onCenterHandleMouseMove);
505+
this._mapOnDebounced('mousemove', this._onCenterHandleMouseMove);
472506
this.map.addLayer(this._getCenterHandleStrokeLayer(), this._circleCenterHandleId);
473507
this._suspendHandleListeners('center');
474508
this.map.once('mouseup', this._onCenterHandleMouseUpOrMapMouseOut);
@@ -507,7 +541,7 @@ class MapboxCircle {
507541

508542
const newCenter = this.center;
509543
this._centerDragActive = false;
510-
this.map.off('mousemove', this._onCenterHandleMouseMove);
544+
this._mapOffDebounced('mousemove', this._onCenterHandleMouseMove);
511545
switch (event.type) {
512546
case 'mouseup': this.map.off('mouseout', this._onCenterHandleMouseUpOrMapMouseOut); break;
513547
case 'mouseout': this.map.off('mouseup', this._onCenterHandleMouseUpOrMapMouseOut); break;
@@ -607,7 +641,7 @@ class MapboxCircle {
607641
*/
608642
_onRadiusHandlesMouseDown(event) {
609643
this._radiusDragActive = true;
610-
this.map.on('mousemove', this._onRadiusHandlesMouseMove);
644+
this._mapOnDebounced('mousemove', this._onRadiusHandlesMouseMove);
611645
this.map.addLayer(this._getRadiusHandlesStrokeLayer(), this._circleRadiusHandlesId);
612646
this._suspendHandleListeners('radius');
613647
this.map.once('mouseup', this._onRadiusHandlesMouseUpOrMapMouseOut);
@@ -646,7 +680,7 @@ class MapboxCircle {
646680

647681
const newRadius = this.radius;
648682
this._radiusDragActive = false;
649-
this.map.off('mousemove', this._onRadiusHandlesMouseMove);
683+
this._mapOffDebounced('mousemove', this._onRadiusHandlesMouseMove);
650684
this.map.removeLayer(this._circleRadiusHandlesStrokeId);
651685
switch (event.type) {
652686
case 'mouseup': this.map.off('mouseout', this._onRadiusHandlesMouseUpOrMapMouseOut); break;

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mapbox-gl-circle",
3-
"version": "1.6.3",
3+
"version": "1.6.4",
44
"author": "Smith Micro Software, Inc.",
55
"license": "ISC",
66
"description": "A google.maps.Circle replacement for Mapbox GL JS API",

0 commit comments

Comments
 (0)