{"action":"created","comment":{"url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/pulls/comments/71247068","id":71247068,"diff_hunk":"@@ -1,96 +1,101 @@\n const CommonSelectors = require('../lib/common_selectors');\n const LineString = require('../feature_types/line_string');\n const isEventAtCoordinates = require('../lib/is_event_at_coordinates');\n-const doubleClickZoom = require('../lib/double_click_zoom');\n const Constants = require('../constants');\n const createVertex = require('../lib/create_vertex');\n \n-module.exports = function(ctx) {\n-  const line = new LineString(ctx, {\n-    type: Constants.geojsonTypes.FEATURE,\n-    properties: {},\n-    geometry: {\n-      type: Constants.geojsonTypes.LINE_STRING,\n-      coordinates: []\n+import ModeInterface from './mode_interface';\n+\n+export default class DrawLineStringMode extends ModeInterface {\n+  constructor(store, ui) {\n+    this.line = new LineString({\n+      type: Constants.geojsonTypes.FEATURE,\n+      properties: {},\n+      geometry: {\n+        type: Constants.geojsonTypes.LINE_STRING,\n+        coordinates: []\n+      }\n+    });\n+\n+    this.currentVertexPosition = 0;\n+\n+    store.add(this.line);\n+    store.clearSelected();\n+    this.doubleClickZoom(false);\n+    ui.queueMapClasses({ mouse: Constants.cursors.ADD });\n+    ui.setActiveButton(Constants.types.LINE);","path":"src/modes/draw_line_string.js","position":34,"original_position":34,"commit_id":"05c08e8ca2b005c6376313622f64888b2e0802be","original_commit_id":"05c08e8ca2b005c6376313622f64888b2e0802be","user":{"login":"davidtheclark","id":628431,"avatar_url":"https://avatars.githubusercontent.com/u/628431?v=3","gravatar_id":"","url":"https://api.github.com/users/davidtheclark","html_url":"https://github.com/davidtheclark","followers_url":"https://api.github.com/users/davidtheclark/followers","following_url":"https://api.github.com/users/davidtheclark/following{/other_user}","gists_url":"https://api.github.com/users/davidtheclark/gists{/gist_id}","starred_url":"https://api.github.com/users/davidtheclark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidtheclark/subscriptions","organizations_url":"https://api.github.com/users/davidtheclark/orgs","repos_url":"https://api.github.com/users/davidtheclark/repos","events_url":"https://api.github.com/users/davidtheclark/events{/privacy}","received_events_url":"https://api.github.com/users/davidtheclark/received_events","type":"User","site_admin":false},"body":"*Or* would we say that custom modes don't get these arguments that expose internals?","created_at":"2016-07-18T23:03:40Z","updated_at":"2016-07-18T23:03:40Z","html_url":"https://github.com/mapbox/mapbox-gl-draw/pull/466#discussion_r71247068","pull_request_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/pulls/466","_links":{"self":{"href":"https://api.github.com/repos/mapbox/mapbox-gl-draw/pulls/comments/71247068"},"html":{"href":"https://github.com/mapbox/mapbox-gl-draw/pull/466#discussion_r71247068"},"pull_request":{"href":"https://api.github.com/repos/mapbox/mapbox-gl-draw/pulls/466"}}},"pull_request":{"url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/pulls/466","id":77676933,"html_url":"https://github.com/mapbox/mapbox-gl-draw/pull/466","diff_url":"https://github.com/mapbox/mapbox-gl-draw/pull/466.diff","patch_url":"https://github.com/mapbox/mapbox-gl-draw/pull/466.patch","issue_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/issues/466","number":466,"state":"open","locked":false,"title":"Modes as Classes","user":{"login":"mcwhittemore","id":1551510,"avatar_url":"https://avatars.githubusercontent.com/u/1551510?v=3","gravatar_id":"","url":"https://api.github.com/users/mcwhittemore","html_url":"https://github.com/mcwhittemore","followers_url":"https://api.github.com/users/mcwhittemore/followers","following_url":"https://api.github.com/users/mcwhittemore/following{/other_user}","gists_url":"https://api.github.com/users/mcwhittemore/gists{/gist_id}","starred_url":"https://api.github.com/users/mcwhittemore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mcwhittemore/subscriptions","organizations_url":"https://api.github.com/users/mcwhittemore/orgs","repos_url":"https://api.github.com/users/mcwhittemore/repos","events_url":"https://api.github.com/users/mcwhittemore/events{/privacy}","received_events_url":"https://api.github.com/users/mcwhittemore/received_events","type":"User","site_admin":false},"body":"@kiRach and @davidtheclark \r\n\r\nAfter @davidtheclark's and my conversations about cleaning up modes and @kiRach observations of how verbose new modes can be I think we should move to make modes into classes. This will let them be extended (so you can make slightly different modes without much work) and will standardize how the mode interfaces with the rest of Draw a bit better.\r\n\r\nThis PR is just a POC. It does not work at all.","created_at":"2016-07-15T20:53:54Z","updated_at":"2016-07-18T23:03:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"62363b1077deb0cbe31c0f8eba99656f716f8af4","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/pulls/466/commits","review_comments_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/pulls/466/comments","review_comment_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/issues/466/comments","statuses_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/statuses/05c08e8ca2b005c6376313622f64888b2e0802be","head":{"label":"mapbox:modes-as-classes","ref":"modes-as-classes","sha":"05c08e8ca2b005c6376313622f64888b2e0802be","user":{"login":"mapbox","id":600935,"avatar_url":"https://avatars.githubusercontent.com/u/600935?v=3","gravatar_id":"","url":"https://api.github.com/users/mapbox","html_url":"https://github.com/mapbox","followers_url":"https://api.github.com/users/mapbox/followers","following_url":"https://api.github.com/users/mapbox/following{/other_user}","gists_url":"https://api.github.com/users/mapbox/gists{/gist_id}","starred_url":"https://api.github.com/users/mapbox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mapbox/subscriptions","organizations_url":"https://api.github.com/users/mapbox/orgs","repos_url":"https://api.github.com/users/mapbox/repos","events_url":"https://api.github.com/users/mapbox/events{/privacy}","received_events_url":"https://api.github.com/users/mapbox/received_events","type":"Organization","site_admin":false},"repo":{"id":29943859,"name":"mapbox-gl-draw","full_name":"mapbox/mapbox-gl-draw","owner":{"login":"mapbox","id":600935,"avatar_url":"https://avatars.githubusercontent.com/u/600935?v=3","gravatar_id":"","url":"https://api.github.com/users/mapbox","html_url":"https://github.com/mapbox","followers_url":"https://api.github.com/users/mapbox/followers","following_url":"https://api.github.com/users/mapbox/following{/other_user}","gists_url":"https://api.github.com/users/mapbox/gists{/gist_id}","starred_url":"https://api.github.com/users/mapbox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mapbox/subscriptions","organizations_url":"https://api.github.com/users/mapbox/orgs","repos_url":"https://api.github.com/users/mapbox/repos","events_url":"https://api.github.com/users/mapbox/events{/privacy}","received_events_url":"https://api.github.com/users/mapbox/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mapbox/mapbox-gl-draw","description":"Draw tools for mapbox-gl-js","fork":false,"url":"https://api.github.com/repos/mapbox/mapbox-gl-draw","forks_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/forks","keys_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/teams","hooks_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/hooks","issue_events_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/issues/events{/number}","events_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/events","assignees_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/assignees{/user}","branches_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/branches{/branch}","tags_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/tags","blobs_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/git/refs{/sha}","trees_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/statuses/{sha}","languages_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/languages","stargazers_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/stargazers","contributors_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/contributors","subscribers_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/subscribers","subscription_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/subscription","commits_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/commits{/sha}","git_commits_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/git/commits{/sha}","comments_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/comments{/number}","issue_comment_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/issues/comments{/number}","contents_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/contents/{+path}","compare_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/merges","archive_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/downloads","issues_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/issues{/number}","pulls_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/pulls{/number}","milestones_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/milestones{/number}","notifications_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/labels{/name}","releases_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/releases{/id}","deployments_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/deployments","created_at":"2015-01-28T01:12:21Z","updated_at":"2016-07-07T02:34:22Z","pushed_at":"2016-07-18T22:53:19Z","git_url":"git://github.com/mapbox/mapbox-gl-draw.git","ssh_url":"git@github.com:mapbox/mapbox-gl-draw.git","clone_url":"https://github.com/mapbox/mapbox-gl-draw.git","svn_url":"https://github.com/mapbox/mapbox-gl-draw","homepage":"","size":4312,"stargazers_count":58,"watchers_count":58,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":21,"mirror_url":null,"open_issues_count":24,"forks":21,"open_issues":24,"watchers":58,"default_branch":"master"}},"base":{"label":"mapbox:master","ref":"master","sha":"2158d98b039b3039dd8578aadd5dd949080cb781","user":{"login":"mapbox","id":600935,"avatar_url":"https://avatars.githubusercontent.com/u/600935?v=3","gravatar_id":"","url":"https://api.github.com/users/mapbox","html_url":"https://github.com/mapbox","followers_url":"https://api.github.com/users/mapbox/followers","following_url":"https://api.github.com/users/mapbox/following{/other_user}","gists_url":"https://api.github.com/users/mapbox/gists{/gist_id}","starred_url":"https://api.github.com/users/mapbox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mapbox/subscriptions","organizations_url":"https://api.github.com/users/mapbox/orgs","repos_url":"https://api.github.com/users/mapbox/repos","events_url":"https://api.github.com/users/mapbox/events{/privacy}","received_events_url":"https://api.github.com/users/mapbox/received_events","type":"Organization","site_admin":false},"repo":{"id":29943859,"name":"mapbox-gl-draw","full_name":"mapbox/mapbox-gl-draw","owner":{"login":"mapbox","id":600935,"avatar_url":"https://avatars.githubusercontent.com/u/600935?v=3","gravatar_id":"","url":"https://api.github.com/users/mapbox","html_url":"https://github.com/mapbox","followers_url":"https://api.github.com/users/mapbox/followers","following_url":"https://api.github.com/users/mapbox/following{/other_user}","gists_url":"https://api.github.com/users/mapbox/gists{/gist_id}","starred_url":"https://api.github.com/users/mapbox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mapbox/subscriptions","organizations_url":"https://api.github.com/users/mapbox/orgs","repos_url":"https://api.github.com/users/mapbox/repos","events_url":"https://api.github.com/users/mapbox/events{/privacy}","received_events_url":"https://api.github.com/users/mapbox/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mapbox/mapbox-gl-draw","description":"Draw tools for mapbox-gl-js","fork":false,"url":"https://api.github.com/repos/mapbox/mapbox-gl-draw","forks_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/forks","keys_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/teams","hooks_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/hooks","issue_events_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/issues/events{/number}","events_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/events","assignees_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/assignees{/user}","branches_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/branches{/branch}","tags_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/tags","blobs_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/git/refs{/sha}","trees_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/statuses/{sha}","languages_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/languages","stargazers_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/stargazers","contributors_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/contributors","subscribers_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/subscribers","subscription_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/subscription","commits_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/commits{/sha}","git_commits_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/git/commits{/sha}","comments_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/comments{/number}","issue_comment_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/issues/comments{/number}","contents_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/contents/{+path}","compare_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/merges","archive_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/downloads","issues_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/issues{/number}","pulls_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/pulls{/number}","milestones_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/milestones{/number}","notifications_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/labels{/name}","releases_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/releases{/id}","deployments_url":"https://api.github.com/repos/mapbox/mapbox-gl-draw/deployments","created_at":"2015-01-28T01:12:21Z","updated_at":"2016-07-07T02:34:22Z","pushed_at":"2016-07-18T22:53:19Z","git_url":"git://github.com/mapbox/mapbox-gl-draw.git","ssh_url":"git@github.com:mapbox/mapbox-gl-draw.git","clone_url":"https://github.com/mapbox/mapbox-gl-draw.git","svn_url":"https://github.com/mapbox/mapbox-gl-draw","homepage":"","size":4312,"stargazers_count":58,"watchers_count":58,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":21,"mirror_url":null,"open_issues_count":24,"forks":21,"open_issues":24,"watchers":58,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mapbox/mapbox-gl-draw/pulls/466"},"html":{"href":"https://github.com/mapbox/mapbox-gl-draw/pull/466"},"issue":{"href":"https://api.github.com/repos/mapbox/mapbox-gl-draw/issues/466"},"comments":{"href":"https://api.github.com/repos/mapbox/mapbox-gl-draw/issues/466/comments"},"review_comments":{"href":"https://api.github.com/repos/mapbox/mapbox-gl-draw/pulls/466/comments"},"review_comment":{"href":"https://api.github.com/repos/mapbox/mapbox-gl-draw/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mapbox/mapbox-gl-draw/pulls/466/commits"},"statuses":{"href":"https://api.github.com/repos/mapbox/mapbox-gl-draw/statuses/05c08e8ca2b005c6376313622f64888b2e0802be"}}}}
{"actor":{"display_login":"davidtheclark"}}