New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ol-ext

Package Overview
Dependencies
Maintainers
1
Versions
89
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ol-ext - npm Package Compare versions

Comparing version 3.2.10 to 3.2.11

22

interaction/Hover.js

@@ -20,5 +20,23 @@ import ol_ext_inherits from '../util/ext'

var dragging = false;
ol_interaction_Interaction.call(this, {
handleEvent: function(e) {
if (e.type=="pointermove") { self.handleMove_(e); }
if (!self.getActive()) return true;
switch(e.type) {
case 'pointerdrag': {
dragging = true;
break;
}
case 'pointerup': {
dragging = false;
break;
}
case 'pointermove': {
if (!dragging) {
self.handleMove_(e);
}
break;
}
}
if (options.handleEvent) return options.handleEvent(e);

@@ -60,3 +78,3 @@ return true;

ol_interaction_Interaction.prototype.setActive.call (this, b);
if (this.cursor_ && this.getMap()) {
if (this.cursor_ && this.getMap() && this.getMap().getTargetElement()) {
var style = this.getMap().getTargetElement().style;

@@ -63,0 +81,0 @@ if (this.previousCursor_ !== undefined) {

53

interaction/Synchronize.js

@@ -29,3 +29,4 @@ /* Copyright (c) 2016 Jean-Marc VIGLINO,

this.maps = options.maps;
this.maps = options.maps || [];
if (options.active === false) this.setActive(false);
};

@@ -64,36 +65,30 @@ ol_ext_inherits(ol_interaction_Synchronize, ol_interaction_Interaction);

/** Auto activate/deactivate controls in the bar
* @param {boolean} b activate/deactivate
*/
ol_interaction_Synchronize.prototype.setActive = function (b) {
ol_interaction_Interaction.prototype.setActive.call(this, b);
this.syncMaps();
};
/** Synchronize the maps
*/
ol_interaction_Synchronize.prototype.syncMaps = function(e) {
*/
ol_interaction_Synchronize.prototype.syncMaps = function() {
if (!this.getActive()) return;
var map = this.getMap();
if (map.get('lockView')) return;
if (!e) e = { type:'all' };
if (map) {
if (map.get('lockView')) return;
for (var i=0; i<this.maps.length; i++) {
this.maps[i].set('lockView', true);
switch (e.type) {
case 'change:rotation': {
if (this.maps[i].getView().getRotation() != map.getView().getRotation())
this.maps[i].getView().setRotation(map.getView().getRotation());
break;
}
case 'change:center': {
if (this.maps[i].getView().getCenter() != map.getView().getCenter()) {
this.maps[i].getView().setCenter(map.getView().getCenter());
}
break;
}
case 'change:resolution': {
if (this.maps[i].getView().getResolution() != map.getView().getResolution()) {
this.maps[i].getView().setResolution(map.getView().getResolution());
}
break;
}
default: {
this.maps[i].getView().setRotation(map.getView().getRotation());
this.maps[i].getView().setCenter(map.getView().getCenter());
this.maps[i].getView().setResolution(map.getView().getResolution());
break;
}
// sync
if (this.maps[i].getView().getRotation() != map.getView().getRotation()) {
this.maps[i].getView().setRotation(map.getView().getRotation());
}
if (this.maps[i].getView().getCenter() != map.getView().getCenter()) {
this.maps[i].getView().setCenter(map.getView().getCenter());
}
if (this.maps[i].getView().getResolution() != map.getView().getResolution()) {
this.maps[i].getView().setResolution(map.getView().getResolution());
}
this.maps[i].set('lockView', false);

@@ -100,0 +95,0 @@ }

@@ -15,2 +15,3 @@ import ol_ext_inherits from '../util/ext'

import {unByKey as ol_Observable_unByKey} from 'ol/Observable'
import { ol_geom_Polygon } from 'ol/geom'

@@ -104,2 +105,4 @@ /** Interaction rotate

this.set('enableRotatedTransform', (options.enableRotatedTransform || false));
/* Keep rectangle angles 90 degrees */
this.set('keepRectangle', (options.keepRectangle || false));

@@ -330,2 +333,3 @@

var i, f, geom;
var keepRectangle = this.get('keepRectangle') && this.selection_.item(0) && (this.selection_.item(0).getGeometry().getType() === 'Polygon');
this.overlayLayer_.getSource().clear();

@@ -335,2 +339,7 @@ if (!this.selection_.getLength()) return;

var ext = this.getGeometryRotateToZero_(this.selection_.item(0)).getExtent();
var coords;
if (keepRectangle) {
coords = this.getGeometryRotateToZero_(this.selection_.item(0)).getCoordinates()[0].slice(0, 4);
coords.unshift(coords[3]);
}
// Clone and extend

@@ -353,4 +362,3 @@ ext = ol_extent_buffer(ext, 0);

}
}
else {
} else {
if (this.ispt_) {

@@ -363,3 +371,3 @@ var p = this.getMap().getPixelFromCoordinate([ext[0], ext[1]]);

}
geom = ol_geom_Polygon_fromExtent(ext);
geom = keepRectangle ? new ol_geom_Polygon([coords]) : ol_geom_Polygon_fromExtent(ext);
if (this.get('enableRotatedTransform') && viewRotation !== 0) {

@@ -416,3 +424,3 @@ geom.rotate(viewRotation, this.getMap().getView().getCenter())

var index = this.selection_.getArray().indexOf(feature);
this.selection_.removeAt(index);
this.selection_.removeAt(index);
}

@@ -569,2 +577,15 @@ this.ispt_ = (this.selection_.getLength()===1 ? (this.selection_.item(0).getGeometry().getType() == "Point") : false);

function projectVectorOnVector(displacement_vector, base) {
var k = (displacement_vector[0] * base[0] + displacement_vector[1] * base[1]) / (base[0] * base[0] + base[1] * base[1]);
return [base[0] * k, base[1] * k];
}
function countVector(start, end) {
return [end[0] - start[0], end[1] - start[1]];
}
function movePoint(point, displacementVector) {
return [point[0]+displacementVector[0], point[1]+displacementVector[1]];
}
/**

@@ -639,2 +660,5 @@ * @param {ol.MapBrowserEvent} evt Map browser event.

}
var keepRectangle = this.get('keepRectangle') && this.geoms_.length <= 1 && this.geoms_[0].getType() == 'Polygon';
var stretch = this.constraint_;
var opt = this.opt_;

@@ -655,2 +679,3 @@ var downCoordinate = this.coordinate_;

var scy = ((dragCoordinate)[1] - (center)[1]) / (downCoordinate[1] - (center)[1]);
var displacementVector = [dragCoordinate[0] - downCoordinate[0], (dragCoordinate)[1] - downCoordinate[1]];

@@ -682,6 +707,66 @@ if (this.get('enableRotatedTransform') && viewRotation !== 0) {

for (var j=0; j<g1.length; j+=dim) {
if (scx!=1) g2[j] = center[0] + (g1[j]-center[0])*scx;
if (scy!=1) g2[j+1] = center[1] + (g1[j+1]-center[1])*scy;
if (!keepRectangle) {
for (var j=0; j<g1.length; j+=dim) {
if (scx!=1) g2[j] = center[0] + (g1[j]-center[0])*scx;
if (scy!=1) g2[j+1] = center[1] + (g1[j+1]-center[1])*scy;
}
} else {
var pointArray = [[6], [0, 8], [2], [4]]
var pointA = [g1[0], g1[1]];
var pointB = [g1[2], g1[3]];
var pointC = [g1[4], g1[5]];
var pointD = [g1[6], g1[7]];
var pointA1 = [g1[8], g1[9]];
if (stretch) {
var base = (opt % 2 === 0) ? countVector(pointA, pointB) : countVector(pointD, pointA);
var projectedVector = projectVectorOnVector(displacementVector, base);
var nextIndex = opt+1 < pointArray.length ? opt+1 : 0;
var coordsToChange = [...pointArray[opt], ...pointArray[nextIndex]];
for (var j = 0; j < g1.length; j += dim) {
g2[j] = coordsToChange.includes(j) ? g1[j] + projectedVector[0] : g1[j];
g2[j + 1] = coordsToChange.includes(j) ? g1[j + 1] + projectedVector[1] : g1[j + 1];
}
} else {
switch (opt) {
case 0:
displacementVector = countVector(pointD, dragCoordinate);
var projectedLeft = projectVectorOnVector(displacementVector, countVector(pointC, pointD));
var projectedRight = projectVectorOnVector(displacementVector, countVector(pointA, pointD));
[g2[0], g2[1]] = movePoint(pointA, projectedLeft);
[g2[4], g2[5]] = movePoint(pointC, projectedRight);
[g2[6], g2[7]] = movePoint(pointD, displacementVector);
[g2[8], g2[9]] = movePoint(pointA1, projectedLeft);
break;
case 1:
displacementVector = countVector(pointA, dragCoordinate);
var projectedLeft = projectVectorOnVector(displacementVector, countVector(pointD, pointA));
var projectedRight = projectVectorOnVector(displacementVector, countVector(pointB, pointA));
[g2[0], g2[1]] = movePoint(pointA, displacementVector);
[g2[2], g2[3]] = movePoint(pointB, projectedLeft);
[g2[6], g2[7]] = movePoint(pointD, projectedRight);
[g2[8], g2[9]] = movePoint(pointA1, displacementVector);
break;
case 2:
displacementVector = countVector(pointB, dragCoordinate);
var projectedLeft = projectVectorOnVector(displacementVector, countVector(pointA, pointB));
var projectedRight = projectVectorOnVector(displacementVector, countVector(pointC, pointB));
[g2[0], g2[1]] = movePoint(pointA, projectedRight);
[g2[2], g2[3]] = movePoint(pointB, displacementVector);
[g2[4], g2[5]] = movePoint(pointC, projectedLeft);
[g2[8], g2[9]] = movePoint(pointA1, projectedRight);
break;
case 3:
displacementVector = countVector(pointC, dragCoordinate);
var projectedLeft = projectVectorOnVector(displacementVector, countVector(pointB, pointC));
var projectedRight = projectVectorOnVector(displacementVector, countVector(pointD, pointC));
[g2[2], g2[3]] = movePoint(pointB, projectedRight);
[g2[4], g2[5]] = movePoint(pointC, displacementVector);
[g2[6], g2[7]] = movePoint(pointD, projectedLeft);
break;
}
}
}
// bug: ol, bad calculation circle geom extent

@@ -688,0 +773,0 @@ if (geometry.getType() == 'Circle') geometry.setCenterAndRadius(geometry.getCenter(), geometry.getRadius());

{
"name": "ol-ext",
"version": "3.2.10",
"version": "3.2.11",
"description": "A set of cool extensions for OpenLayers (ol) in node modules structure",

@@ -5,0 +5,0 @@ "main": "dist/ol-ext.js",

@@ -462,2 +462,9 @@ /** Vanilla JS helper to manipulate DOM without jQuery

dt = 0;
// Add class to handle click (on iframe / double-click)
if (!elt.classList.contains('ol-move')) {
elt.classList.add('ol-hasClick')
setTimeout(function() { elt.classList.remove('ol-hasClick'); }, 500);
} else {
elt.classList.remove('ol-hasClick');
}
});

@@ -464,0 +471,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc