{"action":"created","issue":{"url":"https://api.github.com/repos/nathancahill/Split.js/issues/116","repository_url":"https://api.github.com/repos/nathancahill/Split.js","labels_url":"https://api.github.com/repos/nathancahill/Split.js/issues/116/labels{/name}","comments_url":"https://api.github.com/repos/nathancahill/Split.js/issues/116/comments","events_url":"https://api.github.com/repos/nathancahill/Split.js/issues/116/events","html_url":"https://github.com/nathancahill/Split.js/issues/116","id":284192361,"node_id":"MDU6SXNzdWUyODQxOTIzNjE=","number":116,"title":"Option to drag by fixed amounts/intervals","user":{"login":"adrianbj","id":871211,"node_id":"MDQ6VXNlcjg3MTIxMQ==","avatar_url":"https://avatars0.githubusercontent.com/u/871211?v=4","gravatar_id":"","url":"https://api.github.com/users/adrianbj","html_url":"https://github.com/adrianbj","followers_url":"https://api.github.com/users/adrianbj/followers","following_url":"https://api.github.com/users/adrianbj/following{/other_user}","gists_url":"https://api.github.com/users/adrianbj/gists{/gist_id}","starred_url":"https://api.github.com/users/adrianbj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adrianbj/subscriptions","organizations_url":"https://api.github.com/users/adrianbj/orgs","repos_url":"https://api.github.com/users/adrianbj/repos","events_url":"https://api.github.com/users/adrianbj/events{/privacy}","received_events_url":"https://api.github.com/users/adrianbj/received_events","type":"User","site_admin":false},"labels":[{"id":404510053,"node_id":"MDU6TGFiZWw0MDQ1MTAwNTM=","url":"https://api.github.com/repos/nathancahill/Split.js/labels/easy%20fix","name":"easy fix","color":"c2e0c6","default":false},{"id":253969283,"node_id":"MDU6TGFiZWwyNTM5NjkyODM=","url":"https://api.github.com/repos/nathancahill/Split.js/labels/help%20wanted","name":"help wanted","color":"159818","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":9,"created_at":"2017-12-22T15:42:55Z","updated_at":"2018-10-10T00:19:05Z","closed_at":null,"author_association":"NONE","body":"Thanks for a great script. \r\nJust wondering if you would consider an option to snap dragging to a defined interval of pixels.\r\n\r\nI am using this in conjunction with Ace editor and it would be great to be able to set the `dragInterval` to the same height as the Ace editor `lineHeight` setting. \r\n\r\nI am sure there could be other use cases as well for this functionality.\r\n\r\nThanks!"},"comment":{"url":"https://api.github.com/repos/nathancahill/Split.js/issues/comments/428395972","html_url":"https://github.com/nathancahill/Split.js/issues/116#issuecomment-428395972","issue_url":"https://api.github.com/repos/nathancahill/Split.js/issues/116","id":428395972,"node_id":"MDEyOklzc3VlQ29tbWVudDQyODM5NTk3Mg==","user":{"login":"adrianbj","id":871211,"node_id":"MDQ6VXNlcjg3MTIxMQ==","avatar_url":"https://avatars0.githubusercontent.com/u/871211?v=4","gravatar_id":"","url":"https://api.github.com/users/adrianbj","html_url":"https://github.com/adrianbj","followers_url":"https://api.github.com/users/adrianbj/followers","following_url":"https://api.github.com/users/adrianbj/following{/other_user}","gists_url":"https://api.github.com/users/adrianbj/gists{/gist_id}","starred_url":"https://api.github.com/users/adrianbj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adrianbj/subscriptions","organizations_url":"https://api.github.com/users/adrianbj/orgs","repos_url":"https://api.github.com/users/adrianbj/repos","events_url":"https://api.github.com/users/adrianbj/events{/privacy}","received_events_url":"https://api.github.com/users/adrianbj/received_events","type":"User","site_admin":false},"created_at":"2018-10-10T00:19:05Z","updated_at":"2018-10-10T00:19:05Z","author_association":"NONE","body":"Thanks for the feedback.\r\n\r\n> I would say subtract half of the dragInterval, so that the gutter is more centered under the cursor. Change that line to this:\r\n(Math.ceil(offset / snapInterval) * snapInterval) - (snapInterval / 2)\r\n\r\nI don't think this works. It's actually half the gutter width that works for me - at least in my setup. Take a look at these screencasts.\r\n\r\nThis code:\r\n```\r\n        if (dragInterval !== 0) {\r\n            var draggedInterval = (Math.ceil(offset / dragInterval) * dragInterval) + this[aGutterSize];\r\n            if(offset!== dragInterval) {\r\n                offset = draggedInterval;\r\n            }\r\n        }\r\n```\r\nresults in:\r\n![g1m71doaoq](https://user-images.githubusercontent.com/871211/46705651-2eeb8c80-cc7c-11e8-84c1-fabe03e3aac0.gif)\r\n\r\nBut if I convert to what I think you are suggesting:\r\n```\r\n        if(snapInterval !== 0) {        \r\n            offset = (Math.ceil(offset / dragInterval) * dragInterval) - (dragInterval / 2);\r\n        }\r\n```\r\nI end up with this where the divider is not correctly positioned between the lines:\r\n![mdi8ptv1m3](https://user-images.githubusercontent.com/871211/46705892-555df780-cc7d-11e8-9233-63b58a328a02.gif)\r\n\r\nA simplified working version for me is:\r\n```\r\n        if(dragInterval !== 0) {\r\n            offset = (Math.ceil(offset / dragInterval) * dragInterval) + this[aGutterSize];\r\n        }\r\n```\r\n\r\nBy the way, I am setting the new `dragInterval` value to match the ACEEditor lineHeight. I am also setting splitjs's `minSize` to this same value.\r\n\r\nWhat do you think of the revised version still using the `+ this[aGutterSize]` ? Or is there something I am missing in getting the ` - (dragInterval / 2)` version to work as expected?\r\n\r\nThanks!\r\n\r\n"}}
{"actor":{"display_login":"adrianbj"}}