Customize sticky behaviour of Cart Summary: Magento 2

I finally found the answer to this. The sticky behavior of the cart summary is due to the code in the file magento_root/vendor/magento/theme-frontend-blank/Magento_Theme/web/js/theme.js.

$('.cart-summary').mage('sticky', {
    container: '#maincontent'
});

To remove this functionality, I copied the file theme.js to my theme magento_root/app/design/frontend/customvendor/customtheme/web/js/theme.js and commented out the above piece of code, and removed the magento_root/pub/static/frontend files.

Hope it is helpful to someone else.

theme.js is located under the /vendor/magento/theme-frontend-blank/Magento_Theme/web/js/theme.js

and make replica of this file under your theme's theme module directory

app/design/frontend/YourVendor/YourTheme/Magento_Theme/web/js/theme.js


There is a option in the _stick function that maybe wasn't available when the previous comment was added. You can add spacing to the top of the scrolling container using the spacingTop option as follows:

$('.cart-summary').mage('sticky', {
container: '#maincontent',
spacingTop: 150 //height of sticky header in px
});

There is also an option to delay scrolling until the element has gone out of view called "stickAfter"

See 'lib/web/mage/sticky.js'

theme.js has also now been relocated to:

magento_root/app/design/frontend/customvendor/customtheme/Magento_Theme/js/theme.js