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()
|
||||
|
||||
bs := []users.BannerDTO{}
|
||||
bs := []users.BannerListItemDTO{}
|
||||
for rows.Next() {
|
||||
var b users.BannerDTO
|
||||
var b users.BannerListItemDTO
|
||||
errB := rows.Scan(&b.Id, &b.Image)
|
||||
if errB != nil {
|
||||
r.logger.Error("errB :::", errB)
|
||||
|
||||
@@ -37,8 +37,13 @@ type SubCategoryDTO struct {
|
||||
}
|
||||
|
||||
type DataBannerDTO struct {
|
||||
Banners []BannerDTO `json:"banners"`
|
||||
Count int `json:"count"`
|
||||
Banners []BannerListItemDTO `json:"banners"`
|
||||
Count int `json:"count"`
|
||||
}
|
||||
|
||||
type BannerListItemDTO struct {
|
||||
Id int `json:"id"`
|
||||
Image string `json:"imagePath"`
|
||||
}
|
||||
|
||||
type BannerDTO struct {
|
||||
|
||||
@@ -331,6 +331,6 @@
|
||||
</footer>
|
||||
|
||||
</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>
|
||||
</html>
|
||||
|
||||
@@ -75,12 +75,11 @@ function initializeMainSlider() {
|
||||
|
||||
function onPointerDown(e) {
|
||||
if (e.pointerType === 'mouse' && e.button !== 0) return;
|
||||
e.preventDefault();
|
||||
dragging = true;
|
||||
dragStartX = e.clientX;
|
||||
dragDelta = 0;
|
||||
suppressClick = false;
|
||||
stop();
|
||||
track.classList.add('is-dragging');
|
||||
try {
|
||||
container.setPointerCapture(e.pointerId);
|
||||
} catch (err) {}
|
||||
@@ -89,7 +88,12 @@ function initializeMainSlider() {
|
||||
function onPointerMove(e) {
|
||||
if (!dragging) return;
|
||||
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() {
|
||||
@@ -97,8 +101,7 @@ function initializeMainSlider() {
|
||||
dragging = false;
|
||||
track.classList.remove('is-dragging');
|
||||
|
||||
if (Math.abs(dragDelta) > dragThreshold()) {
|
||||
suppressClick = true;
|
||||
if (suppressClick && Math.abs(dragDelta) > dragThreshold()) {
|
||||
if (dragDelta < 0) {
|
||||
next();
|
||||
} else {
|
||||
@@ -107,6 +110,7 @@ function initializeMainSlider() {
|
||||
} else {
|
||||
dragDelta = 0;
|
||||
applyTransform(true);
|
||||
suppressClick = false;
|
||||
}
|
||||
|
||||
dragDelta = 0;
|
||||
|
||||
Reference in New Issue
Block a user