Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

Chrome, place function #67

Open
jbrozek opened this issue Jan 28, 2016 · 1 comment
Open

Chrome, place function #67

jbrozek opened this issue Jan 28, 2016 · 1 comment

Comments

@jbrozek
Copy link

jbrozek commented Jan 28, 2016

Using Chrome 48.0.2564.97

You can replicate on your demo page (http://makingsense.github.io/moment-datepicker/)

  1. Scroll down half way
  2. Click the input in "Using KnockOut.js Date binding."
  3. Scroll down further, you can see the calendar below

I fixed locally by doing the following

place: function () {
            var sourceItem = this.component ? this.component : this.element;
            var offset = sourceItem.offset();

            //var viewportOffset = this.$viewport.offset();
            //var scrollTop = this.$viewport.scrollTop();

            var zIndex = parseInt(this.element.parents().filter(function () {
                var zIndex = $(this).css('z-index');
                return zIndex != 'auto' && zIndex != '0';
            }).first().css('z-index')) + 10;

            //console.log('top: ' + (offset.top + this.height + scrollTop - viewportOffset.top));
            //console.log('offset.top: ' + offset.top);
            //console.log('this.height: ' + this.height);
            //console.log('scrollTop: ' + scrollTop);
            //console.log('viewportOffset.top: ' + viewportOffset.top);

            if (this.calendarPlacement == 'left') {
                this.picker.css({
                    top: offset.top + this.height,
                    left: offset.left + sourceItem[0].offsetWidth - this.picker[0].offsetWidth
                });
            } else {
                this.picker.css({
                    top: offset.top + this.height,
                    left: offset.left,
                    zIndex : zIndex
                });
            }
        },
@leighelse
Copy link

This is a really helpful fix. I can confirm it resolves the positioning problem with webkit browsers, but does not adversely affect any of the others I've tested.

joanvila added a commit to joanvila/moment-datepicker that referenced this issue Mar 16, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants