diff --git a/README.md b/README.md
index ea8e85f..b4bf5ab 100644
--- a/README.md
+++ b/README.md
@@ -28,9 +28,9 @@ Funkcjonalności aplikacji koncentrują się na tworzeniu i modyfikacji kształt
- [x] 14. Usunięcie tekstu
### Plansza i akcje na niej
-- [ ] 15. Przybliżenie planszy
-- [ ] 16. Oddalenie planszy
-- [ ] 17. Przewijanie planszy
+- [x] 15. Przybliżenie planszy
+- [x] 16. Oddalenie planszy
+- [x] 17. Przewijanie planszy
*P.S. Jak będzie brakować funkcjonalności:*
- Obracanie kształtu
diff --git a/index.html b/index.html
index ee73fb7..5b13e99 100644
--- a/index.html
+++ b/index.html
@@ -18,6 +18,11 @@
@@ -207,7 +212,8 @@
selectedElement = elementView.model;
});
- paper.on('blank:pointerdown', function () {
+ let panStart = null;
+ paper.on('blank:pointerdown', function (evt) {
if (activeElementView) {
if (typeof activeElementView.hideTools === 'function') {
activeElementView.hideTools();
@@ -218,6 +224,29 @@
activeElementView = null;
}
selectedElement = null;
+ //ruszanie caloscia
+ panStart = {
+ x: evt.clientX,
+ y: evt.clientY,
+ tx: paper.translate().tx,
+ ty: paper.translate().ty
+ };
+ paper.$el.css('cursor', 'grabbing');
+ });
+
+ $(document).on('mousemove', function (evt) {
+ if (panStart) {
+ const dx = evt.clientX - panStart.x;
+ const dy = evt.clientY - panStart.y;
+ paper.translate(panStart.tx + dx, panStart.ty + dy);
+ }
+ });
+
+ $(document).on('mouseup', function () {
+ if (panStart) {
+ panStart = null;
+ paper.$el.css('cursor', 'default');
+ }
});
//add text to text block - START
@@ -240,6 +269,33 @@
}
});
//add text to text block - END
+
+ // Zoom
+ const zoomStep = 0.2;
+ const minScale = 0.2;
+ const maxScale = 3.0;
+
+ $('#zoom-in').click(function () {
+ const currentScale = paper.scale().sx;
+ const newScale = Math.min(maxScale, currentScale + zoomStep);
+ paper.scale(newScale, newScale);
+ });
+
+ $('#zoom-out').click(function () {
+ const currentScale = paper.scale().sx;
+ const newScale = Math.max(minScale, currentScale - zoomStep);
+ paper.scale(newScale, newScale);
+ });
+
+ // Zoom za pomoca kolka myszy
+ paper.on('blank:mousewheel cell:mousewheel', function (evt, x, y, delta) {
+ evt.preventDefault();
+ const oldScale = paper.scale().sx;
+ const zoomFactor = 0.2;
+ let newScale = oldScale * (1 + delta * zoomFactor);
+ newScale = Math.max(minScale, Math.min(maxScale, newScale));
+ paper.scale(newScale, newScale, x, y);
+ });
});