Dodano funkcje przybliżania, oddalania i
przewijania planszy.
This commit is contained in:
@@ -28,9 +28,9 @@ Funkcjonalności aplikacji koncentrują się na tworzeniu i modyfikacji kształt
|
|||||||
- [x] 14. Usunięcie tekstu
|
- [x] 14. Usunięcie tekstu
|
||||||
|
|
||||||
### Plansza i akcje na niej
|
### Plansza i akcje na niej
|
||||||
- [ ] 15. Przybliżenie planszy
|
- [x] 15. Przybliżenie planszy
|
||||||
- [ ] 16. Oddalenie planszy
|
- [x] 16. Oddalenie planszy
|
||||||
- [ ] 17. Przewijanie planszy
|
- [x] 17. Przewijanie planszy
|
||||||
|
|
||||||
*P.S. Jak będzie brakować funkcjonalności:*
|
*P.S. Jak będzie brakować funkcjonalności:*
|
||||||
- Obracanie kształtu
|
- Obracanie kształtu
|
||||||
|
|||||||
58
index.html
58
index.html
@@ -18,6 +18,11 @@
|
|||||||
<div id="shape-diamond" class="shape" data-type="diamond"></div>
|
<div id="shape-diamond" class="shape" data-type="diamond"></div>
|
||||||
<div id="shape-text" class="shape" data-type="text">Tekst</div>
|
<div id="shape-text" class="shape" data-type="text">Tekst</div>
|
||||||
</div>
|
</div>
|
||||||
|
<p>Zoom</p>
|
||||||
|
<div class="zoom-wrapper toolbar-wrapper">
|
||||||
|
<button id="zoom-in">+</button>
|
||||||
|
<button id="zoom-out">-</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="canvas-container">
|
<div class="canvas-container">
|
||||||
<div id="paper"></div>
|
<div id="paper"></div>
|
||||||
@@ -207,7 +212,8 @@
|
|||||||
selectedElement = elementView.model;
|
selectedElement = elementView.model;
|
||||||
});
|
});
|
||||||
|
|
||||||
paper.on('blank:pointerdown', function () {
|
let panStart = null;
|
||||||
|
paper.on('blank:pointerdown', function (evt) {
|
||||||
if (activeElementView) {
|
if (activeElementView) {
|
||||||
if (typeof activeElementView.hideTools === 'function') {
|
if (typeof activeElementView.hideTools === 'function') {
|
||||||
activeElementView.hideTools();
|
activeElementView.hideTools();
|
||||||
@@ -218,6 +224,29 @@
|
|||||||
activeElementView = null;
|
activeElementView = null;
|
||||||
}
|
}
|
||||||
selectedElement = 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
|
//add text to text block - START
|
||||||
@@ -240,6 +269,33 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
//add text to text block - END
|
//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);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
46
style.css
46
style.css
@@ -69,4 +69,48 @@
|
|||||||
.toolbar-wrapper {
|
.toolbar-wrapper {
|
||||||
padding-bottom: 30px;
|
padding-bottom: 30px;
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.zoom-wrapper {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 15px;
|
||||||
|
padding: 10px 20px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.zoom-wrapper button {
|
||||||
|
background: white;
|
||||||
|
color: #3498db;
|
||||||
|
border: none;
|
||||||
|
border-radius: 50%;
|
||||||
|
width: 50px;
|
||||||
|
height: 50px;
|
||||||
|
font-size: 24px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
cursor: pointer;
|
||||||
|
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.zoom-wrapper button:hover {
|
||||||
|
background: #2980b9;
|
||||||
|
color: white;
|
||||||
|
transform: scale(1.1);
|
||||||
|
box-shadow: 0 6px 15px rgba(0, 0, 0, 0.25);
|
||||||
|
}
|
||||||
|
|
||||||
|
.zoom-wrapper button:active {
|
||||||
|
transform: scale(0.95);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Fajny efekt przy najechaniu */
|
||||||
|
.zoom-wrapper button i {
|
||||||
|
transition: transform 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.zoom-wrapper button:hover i {
|
||||||
|
transform: scale(1.2);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user