Slim banner list to id/imagePath and fix slider click navigation.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -137,9 +137,9 @@ func (r repository) GetBanners(ctx context.Context, limit, page int) (users.Data
|
|||||||
}
|
}
|
||||||
defer rows.Close()
|
defer rows.Close()
|
||||||
|
|
||||||
bs := []users.BannerDTO{}
|
bs := []users.BannerListItemDTO{}
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var b users.BannerDTO
|
var b users.BannerListItemDTO
|
||||||
errB := rows.Scan(&b.Id, &b.Image)
|
errB := rows.Scan(&b.Id, &b.Image)
|
||||||
if errB != nil {
|
if errB != nil {
|
||||||
r.logger.Error("errB :::", errB)
|
r.logger.Error("errB :::", errB)
|
||||||
|
|||||||
@@ -37,8 +37,13 @@ type SubCategoryDTO struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type DataBannerDTO struct {
|
type DataBannerDTO struct {
|
||||||
Banners []BannerDTO `json:"banners"`
|
Banners []BannerListItemDTO `json:"banners"`
|
||||||
Count int `json:"count"`
|
Count int `json:"count"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type BannerListItemDTO struct {
|
||||||
|
Id int `json:"id"`
|
||||||
|
Image string `json:"imagePath"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type BannerDTO struct {
|
type BannerDTO struct {
|
||||||
|
|||||||
@@ -331,6 +331,6 @@
|
|||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
<script src="/js/slider.js?v=2"></script>
|
<script src="/js/slider.js?v=3"></script>
|
||||||
<script src="/js/app.js?v=2"></script>
|
<script src="/js/app.js?v=2"></script>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -75,12 +75,11 @@ function initializeMainSlider() {
|
|||||||
|
|
||||||
function onPointerDown(e) {
|
function onPointerDown(e) {
|
||||||
if (e.pointerType === 'mouse' && e.button !== 0) return;
|
if (e.pointerType === 'mouse' && e.button !== 0) return;
|
||||||
e.preventDefault();
|
|
||||||
dragging = true;
|
dragging = true;
|
||||||
dragStartX = e.clientX;
|
dragStartX = e.clientX;
|
||||||
dragDelta = 0;
|
dragDelta = 0;
|
||||||
|
suppressClick = false;
|
||||||
stop();
|
stop();
|
||||||
track.classList.add('is-dragging');
|
|
||||||
try {
|
try {
|
||||||
container.setPointerCapture(e.pointerId);
|
container.setPointerCapture(e.pointerId);
|
||||||
} catch (err) {}
|
} catch (err) {}
|
||||||
@@ -89,7 +88,12 @@ function initializeMainSlider() {
|
|||||||
function onPointerMove(e) {
|
function onPointerMove(e) {
|
||||||
if (!dragging) return;
|
if (!dragging) return;
|
||||||
dragDelta = e.clientX - dragStartX;
|
dragDelta = e.clientX - dragStartX;
|
||||||
applyTransform(false);
|
if (Math.abs(dragDelta) > dragThreshold()) {
|
||||||
|
suppressClick = true;
|
||||||
|
if (e.cancelable) e.preventDefault();
|
||||||
|
track.classList.add('is-dragging');
|
||||||
|
applyTransform(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onPointerUp() {
|
function onPointerUp() {
|
||||||
@@ -97,8 +101,7 @@ function initializeMainSlider() {
|
|||||||
dragging = false;
|
dragging = false;
|
||||||
track.classList.remove('is-dragging');
|
track.classList.remove('is-dragging');
|
||||||
|
|
||||||
if (Math.abs(dragDelta) > dragThreshold()) {
|
if (suppressClick && Math.abs(dragDelta) > dragThreshold()) {
|
||||||
suppressClick = true;
|
|
||||||
if (dragDelta < 0) {
|
if (dragDelta < 0) {
|
||||||
next();
|
next();
|
||||||
} else {
|
} else {
|
||||||
@@ -107,6 +110,7 @@ function initializeMainSlider() {
|
|||||||
} else {
|
} else {
|
||||||
dragDelta = 0;
|
dragDelta = 0;
|
||||||
applyTransform(true);
|
applyTransform(true);
|
||||||
|
suppressClick = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
dragDelta = 0;
|
dragDelta = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user