Skip to content

Commit

Permalink
Merge pull request #198 from vtex-apps/feature/offset-scroll-top-mobile
Browse files Browse the repository at this point in the history
Add scroll top to mobile viewport when editing address
  • Loading branch information
wender authored Jun 27, 2023
2 parents 0a8f8c1 + cb5ebd5 commit 441d269
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Added
- Added offset scroll on mobile when user changes their address

## [0.11.1] - 2023-05-19

### Added
Expand Down
2 changes: 1 addition & 1 deletion checkout-ui-custom/checkout6-custom.js

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions checkout-ui-custom/src/_js/_v.custom.checkout.ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,22 @@ class checkoutCustom {
})
}

handleBreakpointChange() {
if (window.innerWidth <= 767) {
$('body').on('click', '#edit-address-button', () => {
setTimeout(() => {
const shippingDataElement = document.getElementById('shipping-data')
const offset = shippingDataElement.offsetTop - 200

window.scrollTo({
top: offset,
behavior: 'smooth',
})
}, 500)
})
}
}

removeMCLoader() {
$(`.mini-cart .cart-items`).addClass('v-loaded')
}
Expand Down Expand Up @@ -1076,6 +1092,10 @@ class checkoutCustom {
window.location = $(this).closest('.checkout-steps_item').attr('data-url')
})

window.addEventListener('resize', _this.handleBreakpointChange)

_this.handleBreakpointChange()

$('body').on(
'click',
'.vtex-omnishipping-1-x-linkEdit.link-edit',
Expand Down
2 changes: 1 addition & 1 deletion node/templates/checkout6-custom.js

Large diffs are not rendered by default.

0 comments on commit 441d269

Please sign in to comment.