{"action":"created","issue":{"url":"https://api.github.com/repos/panorama-ed/maximize-select2-height/issues/5","labels_url":"https://api.github.com/repos/panorama-ed/maximize-select2-height/issues/5/labels{/name}","comments_url":"https://api.github.com/repos/panorama-ed/maximize-select2-height/issues/5/comments","events_url":"https://api.github.com/repos/panorama-ed/maximize-select2-height/issues/5/events","html_url":"https://github.com/panorama-ed/maximize-select2-height/issues/5","id":121265257,"number":5,"title":"Possible not to memoize top offset?","user":{"login":"elmart","id":135757,"avatar_url":"https://avatars.githubusercontent.com/u/135757?v=3","gravatar_id":"","url":"https://api.github.com/users/elmart","html_url":"https://github.com/elmart","followers_url":"https://api.github.com/users/elmart/followers","following_url":"https://api.github.com/users/elmart/following{/other_user}","gists_url":"https://api.github.com/users/elmart/gists{/gist_id}","starred_url":"https://api.github.com/users/elmart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elmart/subscriptions","organizations_url":"https://api.github.com/users/elmart/orgs","repos_url":"https://api.github.com/users/elmart/repos","events_url":"https://api.github.com/users/elmart/events{/privacy}","received_events_url":"https://api.github.com/users/elmart/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-12-09T15:05:36Z","updated_at":"2016-01-07T14:21:06Z","closed_at":null,"body":"Plugin currently memoizes element's top offset the first time it needs it. In `topOffset()`:\r\n```\r\n    // We only want to calculate the vertical offset of the DOM element once,\r\n    // both to be more efficient and because when the dropdown is rendered\r\n    // upward we are changing its offset the first time we adjust its height.\r\n    if (typeof $select2Results.data(OFFSET_KEY) === \"undefined\") {\r\n      $select2Results.data(OFFSET_KEY, $select2Results.offset().top);\r\n    }\r\n```\r\nNow, I have a select2 within a floating modal window. There, it's not rare for the user to move the window between one select2:open event and the next one. That makes memoized top offset obsolete, and consequent optimal height calculation wrong.\r\n\r\nI tried to remove enclosing if, to always calculate the value, but then, I have wrong behaviour when rendering upwards. The comment above mentions something about this, but I'm not sure about which the correct fix would be. \r\n\r\nAny indication about how to proceed, please?\r\n"},"comment":{"url":"https://api.github.com/repos/panorama-ed/maximize-select2-height/issues/comments/169677435","html_url":"https://github.com/panorama-ed/maximize-select2-height/issues/5#issuecomment-169677435","issue_url":"https://api.github.com/repos/panorama-ed/maximize-select2-height/issues/5","id":169677435,"user":{"login":"elmart","id":135757,"avatar_url":"https://avatars.githubusercontent.com/u/135757?v=3","gravatar_id":"","url":"https://api.github.com/users/elmart","html_url":"https://github.com/elmart","followers_url":"https://api.github.com/users/elmart/followers","following_url":"https://api.github.com/users/elmart/following{/other_user}","gists_url":"https://api.github.com/users/elmart/gists{/gist_id}","starred_url":"https://api.github.com/users/elmart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elmart/subscriptions","organizations_url":"https://api.github.com/users/elmart/orgs","repos_url":"https://api.github.com/users/elmart/repos","events_url":"https://api.github.com/users/elmart/events{/privacy}","received_events_url":"https://api.github.com/users/elmart/received_events","type":"User","site_admin":false},"created_at":"2016-01-07T14:21:06Z","updated_at":"2016-01-07T14:21:06Z","body":"Hi guys. I'm very sorry I didn't respond before. I had my computer broken and it took some time to repair.\r\n\r\nProposed solution doesn't work in the dropdownDownwards case, but I had it working with a small fix (there was a mistaken sign). I'll comment the exact line in the PR.\r\nApart from that, there's a little flickering which gets disturbing, but that's a different issue, and I'm afraid that would be more difficult/impossible to solve from outside select2.\r\n\r\nSo, once the appointed problem is solved, I consider this fixed.\r\n\r\nThx for your time."}}