Following is a layer: pointers anywhere on the page, and a list of what to follow
A pointer is what it points at, not where it is. What goes out is the element under it, as a path from <body> with where it sits in each element on the way down, so over a button it is over the watcher's button however differently the two windows are laid out. In an SVG the point is in the SVG's own units, so on the stage it stays on the drawing at any zoom. A path that half resolves dims at the deepest element both pages share; one scrolled out of a pane waits at its edge. A press shows as a ring. The ▾ beside the eye says what you follow, each a switch: tab, frame and play with speed, loop and marks; selection; timeline rows; onion, tracing and mat; tool and brush; which panels are shut; panel scroll; pointers. What you let go of you neither take nor send, so looking around never moves the party, and taking it back catches up. The pool and the inspector are both `section.pane`, so a path by first class put a pointer on the pool whenever one window had it shut. A step now matches on the whole class list, and falls back to the first class only for state classes like `on` and `selected`. All of it lives in `arthur.follow` and `follow/`, switched on by one line in `arthur.core`. Collab no longer knows parties exist: it keeps a roster of whatever each peer says about itself, and lets a listener hear the room. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
7c637576b2
commit
00e94c025a
10 changed files with 684 additions and 294 deletions
|
|
@ -5,7 +5,7 @@ socket is read-only for the document, and a dropped socket cannot lose a write.
|
||||||
PRESENCE, which peers gossip between themselves: all the server does is hand out
|
PRESENCE, which peers gossip between themselves: all the server does is hand out
|
||||||
a connection id and stamp the sender's identity onto every message, so nobody can
|
a connection id and stamp the sender's identity onto every message, so nobody can
|
||||||
post as somebody else. A party — people following each other — is worked out in
|
post as somebody else. A party — people following each other — is worked out in
|
||||||
the browsers from that gossip (`arthur.domain.party`); nothing here knows of it.
|
the browsers from that gossip (`arthur.follow`); nothing here knows of it.
|
||||||
"""
|
"""
|
||||||
import json
|
import json
|
||||||
import uuid
|
import uuid
|
||||||
|
|
@ -33,10 +33,10 @@ def broadcast(project_id, delta, kind="delta"):
|
||||||
|
|
||||||
|
|
||||||
class ProjectConsumer(AsyncWebsocketConsumer):
|
class ProjectConsumer(AsyncWebsocketConsumer):
|
||||||
# `state` is who you are and which party you carry, and is remembered for
|
# `state` is what each of us says about ourselves, and is remembered for the
|
||||||
# the next joiner. `nav` and `cursor` are where a party is looking, and are
|
# next joiner. The rest are `arthur.follow`'s — where a party is looking —
|
||||||
# stale the moment the next one is sent, so they are only passed on.
|
# and are stale the moment the next is sent, so they are only passed on.
|
||||||
RELAYED = ("state", "nav", "cursor")
|
RELAYED = ("state", "nav", "cursor", "scroll") # follow: all but "state"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def room(self):
|
def room(self):
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@
|
||||||
[arthur.events.paint]
|
[arthur.events.paint]
|
||||||
[arthur.events.project :as project]
|
[arthur.events.project :as project]
|
||||||
[arthur.events.ui]
|
[arthur.events.ui]
|
||||||
|
[arthur.follow :as follow]
|
||||||
[arthur.subs.playback]
|
[arthur.subs.playback]
|
||||||
[arthur.subs.render]
|
[arthur.subs.render]
|
||||||
[arthur.subs.ui]
|
[arthur.subs.ui]
|
||||||
|
|
@ -45,6 +46,7 @@
|
||||||
(rf/dispatch [::project/list-symbols])
|
(rf/dispatch [::project/list-symbols])
|
||||||
;; After the blank document, so an address that names a project opens it over
|
;; After the blank document, so an address that names a project opens it over
|
||||||
;; the blank one, and the blank one is what a bad address leaves on screen.
|
;; the blank one, and the blank one is what a bad address leaves on screen.
|
||||||
|
(follow/install!) ; following someone: arthur.follow
|
||||||
(collab/start!)
|
(collab/start!)
|
||||||
(shortcuts/install!)
|
(shortcuts/install!)
|
||||||
(reset! root (rdc/create-root (js/document.getElementById "app")))
|
(reset! root (rdc/create-root (js/document.getElementById "app")))
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,6 @@
|
||||||
The next save sends ours, and if theirs moved since, it answers 409 and we catch
|
The next save sends ours, and if theirs moved since, it answers 409 and we catch
|
||||||
up, and the save after that is ours."
|
up, and the save after that is ours."
|
||||||
(:require [arthur.domain.leaf :as leaf]
|
(:require [arthur.domain.leaf :as leaf]
|
||||||
[arthur.domain.party :as party]
|
|
||||||
[arthur.domain.project :as project]
|
[arthur.domain.project :as project]
|
||||||
[arthur.events.edit :as edit]
|
[arthur.events.edit :as edit]
|
||||||
[arthur.events.playback :as pb]
|
[arthur.events.playback :as pb]
|
||||||
|
|
@ -24,8 +23,7 @@
|
||||||
[arthur.footage.store :as store]
|
[arthur.footage.store :as store]
|
||||||
[arthur.fx.http :as http]
|
[arthur.fx.http :as http]
|
||||||
[clojure.string :as str]
|
[clojure.string :as str]
|
||||||
[re-frame.core :as rf]
|
[re-frame.core :as rf]))
|
||||||
[re-frame.db :as rf-db]))
|
|
||||||
|
|
||||||
;; ---------------------------------------------------------------------------
|
;; ---------------------------------------------------------------------------
|
||||||
;; the address
|
;; the address
|
||||||
|
|
@ -126,30 +124,14 @@
|
||||||
(rf/dispatch [::peers-reset :elsewhere])
|
(rf/dispatch [::peers-reset :elsewhere])
|
||||||
(when id (open! id)))
|
(when id (open! id)))
|
||||||
|
|
||||||
(defn- send! [msg]
|
(defn send!
|
||||||
|
"Say `msg` to the room, if we are in it; otherwise it is dropped."
|
||||||
|
[msg]
|
||||||
(when-let [^js s @socket]
|
(when-let [^js s @socket]
|
||||||
(when (= 1 (.-readyState s)) ; OPEN; otherwise it is dropped
|
(when (= 1 (.-readyState s)) ; OPEN
|
||||||
(.send s (js/JSON.stringify (clj->js msg))))))
|
(.send s (js/JSON.stringify (clj->js msg))))))
|
||||||
|
|
||||||
(defn- throttled
|
|
||||||
"`send!`, at most once every `gap` ms: the first at once, so a move feels
|
|
||||||
immediate, and the last always, so a party lands where a scrub ENDED rather
|
|
||||||
than wherever the last message let through happened to be."
|
|
||||||
[gap]
|
|
||||||
(let [sent (atom 0) timer (atom nil) pending (atom nil)
|
|
||||||
flush! (fn []
|
|
||||||
(reset! timer nil)
|
|
||||||
(reset! sent (js/Date.now))
|
|
||||||
(when-let [m @pending] (reset! pending nil) (send! m)))]
|
|
||||||
(fn [msg]
|
|
||||||
(reset! pending msg)
|
|
||||||
(when-not @timer
|
|
||||||
(let [due (- gap (- (js/Date.now) @sent))]
|
|
||||||
(if (pos? due) (reset! timer (js/setTimeout flush! due)) (flush!)))))))
|
|
||||||
|
|
||||||
(rf/reg-fx ::send! send!)
|
(rf/reg-fx ::send! send!)
|
||||||
(rf/reg-fx ::nav! (throttled 120))
|
|
||||||
(def ^:private cursor! (throttled 40))
|
|
||||||
|
|
||||||
(rf/reg-fx
|
(rf/reg-fx
|
||||||
::follow!
|
::follow!
|
||||||
|
|
@ -203,225 +185,80 @@
|
||||||
[:dispatch [::events.project/save]]))))))
|
[:dispatch [::events.project/save]]))))))
|
||||||
|
|
||||||
;; ---------------------------------------------------------------------------
|
;; ---------------------------------------------------------------------------
|
||||||
;; presence, and following
|
;; presence
|
||||||
;;
|
;;
|
||||||
;; `:peers` is the roster, us included, as the room gossips it; `arthur.domain.
|
;; `:peers` is the roster, us included, as the room gossips it: cid → `{:cid
|
||||||
;; party` works out from it who is following whom. `:party` is ours alone:
|
;; :user}` and whatever else each of us says about ourselves. `:presence` is
|
||||||
;; whether we let people follow us, the party to say again after a dropped
|
;; what WE say, and it is said again on every welcome, so a dropped socket comes
|
||||||
;; socket, and a move we could not take yet. `:cursors` are where our party's
|
;; back as it left. Nothing here reads past `:cid` and `:user`: what the rest
|
||||||
;; pointers are on the stage.
|
;; means belongs to whoever `listen!`s.
|
||||||
|
|
||||||
(def ^:private followable-key "arthur/followable")
|
(defonce ^:private listeners (atom #{}))
|
||||||
|
|
||||||
(defn- followable? [db]
|
(defn listen!
|
||||||
(get-in db [:party :joinable]
|
"Hear the room: every message it sends, as `[event-id message]` once the roster
|
||||||
(try (not= "0" (.getItem js/localStorage followable-key))
|
has it, and `#js {:kind \"reset\" :elsewhere bool}` when the room is lost."
|
||||||
(catch :default _ true))))
|
[event-id]
|
||||||
|
(swap! listeners conj event-id))
|
||||||
|
|
||||||
(rf/reg-fx
|
(defn- heard [fx ^js m]
|
||||||
::remember-followable
|
(update fx :fx (fnil into []) (map (fn [l] [:dispatch [l m]])) @listeners))
|
||||||
(fn [on?] (try (.setItem js/localStorage followable-key (if on? "1" "0"))
|
|
||||||
(catch :default _ nil))))
|
|
||||||
|
|
||||||
(defn- mine [db] (party/party-of (:peers db) (:peer-cid db)))
|
(defn say
|
||||||
|
"`db` with `fields` part of what we say about ourselves, and the effects that
|
||||||
|
say it. `once` rides along on this message only."
|
||||||
|
([db fields] (say db fields nil))
|
||||||
|
([db fields once]
|
||||||
|
(let [db (cond-> (update db :presence merge fields)
|
||||||
|
(:peer-cid db) (update-in [:peers (:peer-cid db)] merge fields))]
|
||||||
|
{:db db ::send! (merge {:kind "state"} (:presence db) once)})))
|
||||||
|
|
||||||
(defn- state-msg
|
(defn colour
|
||||||
"What we say about ourselves. `joining` names whoever we just followed: they
|
"A collaborator's colour, the same on their face and anywhere else they show,
|
||||||
take on the party if they are on their own, and everyone else reads it as us
|
and the same in every browser that sees them: it is read off their cid."
|
||||||
being the newcomer."
|
[cid]
|
||||||
([db] (state-msg db nil))
|
(str "hsl(" (mod (reduce #(+ (* 31 %1) (.charCodeAt %2 0)) 0 cid) 360) " 60% 42%)"))
|
||||||
([db joining]
|
|
||||||
{:kind "state" :party (mine db) :joinable (followable? db) :joining joining}))
|
|
||||||
|
|
||||||
(defn- sid->wire [sid] (subs (str sid) 1))
|
|
||||||
|
|
||||||
(defn- nav-msg
|
|
||||||
"Where we are, as the party sees it: the open tab, the frame, and whether it
|
|
||||||
plays."
|
|
||||||
[db]
|
|
||||||
{:kind "nav" :open (sid->wire (get-in db [:ui :open]))
|
|
||||||
:frame (get-in db [:playback :frame] 0)
|
|
||||||
:playing (boolean (get-in db [:playback :playing?]))})
|
|
||||||
|
|
||||||
(defn- upsert
|
(defn- upsert
|
||||||
"A peer's message laid over what we knew of them: a `join` says nothing of a
|
"A peer's message laid over what we knew of them: one that does not mention a
|
||||||
party, and must not take one away."
|
field must not take it away."
|
||||||
[db ^js m]
|
[db ^js m]
|
||||||
(let [cid (.-cid m)]
|
(update-in db [:peers (.-cid m)] merge
|
||||||
(update-in db [:peers cid] merge
|
(dissoc (js->clj m :keywordize-keys true) :kind)))
|
||||||
(cond-> {:cid cid :user (.-user m)}
|
|
||||||
(js-in "party" m) (assoc :party (.-party m))
|
|
||||||
(js-in "joinable" m) (assoc :joinable (boolean (.-joinable m)))))))
|
|
||||||
|
|
||||||
(rf/reg-event-db
|
(rf/reg-event-fx
|
||||||
::peers-reset
|
::peers-reset
|
||||||
;; Off the wire, everyone we could see is a guess. Our party id is kept when it
|
;; Off the wire, everyone we could see is a guess. `elsewhere?` is another room.
|
||||||
;; is the same room coming back: it is only a name the members still carry, so
|
(fn [{:keys [db]} [_ elsewhere?]]
|
||||||
;; rejoining is saying it again. Another room forgets it.
|
(heard {:db (assoc db :peers {})} #js {:kind "reset" :elsewhere elsewhere?})))
|
||||||
(fn [db [_ elsewhere?]]
|
|
||||||
(-> db
|
|
||||||
(assoc :peers {} :cursors {})
|
|
||||||
(assoc-in [:party :rejoin] (when-not elsewhere?
|
|
||||||
(or (mine db) (get-in db [:party :rejoin]))))
|
|
||||||
(assoc-in [:party :parked] nil))))
|
|
||||||
|
|
||||||
(rf/reg-event-fx
|
(rf/reg-event-fx
|
||||||
::message
|
::message
|
||||||
(fn [{:keys [db]} [_ ^js m]]
|
(fn [{:keys [db]} [_ ^js m]]
|
||||||
|
(heard
|
||||||
(case (.-kind m)
|
(case (.-kind m)
|
||||||
"welcome" (let [cid (.-cid m)
|
"welcome" (let [cid (.-cid m)]
|
||||||
db (-> db
|
{:db (assoc db :peer-cid cid
|
||||||
(assoc :peers {} :peer-cid cid)
|
:peers {cid (merge {:cid cid :user (.-user m)} (:presence db))})
|
||||||
(assoc-in [:peers cid] {:cid cid :user (.-user m)
|
::send! (merge {:kind "state"} (:presence db))
|
||||||
:party (get-in db [:party :rejoin])
|
|
||||||
:joinable (followable? db)})
|
|
||||||
(assoc-in [:party :rejoin] nil))]
|
|
||||||
;; Anything written between our GET and our joining the room
|
;; Anything written between our GET and our joining the room
|
||||||
;; was broadcast to a room we were not in yet.
|
;; was broadcast to a room we were not in yet.
|
||||||
{:db db ::send! (state-msg db) :dispatch [::catch-up]})
|
:dispatch [::catch-up]})
|
||||||
"roster" {:db (reduce upsert db (array-seq (.-peers m)))}
|
"roster" {:db (reduce upsert db (array-seq (.-peers m)))}
|
||||||
"join" {:db (upsert db m)}
|
("join" "state") {:db (upsert db m)}
|
||||||
"state" {:dispatch [::peer-state m]}
|
"leave" {:db (update db :peers dissoc (.-cid m))}
|
||||||
"leave" {:db (-> db
|
|
||||||
(update :peers dissoc (.-cid m))
|
|
||||||
(update :cursors dissoc (.-cid m)))}
|
|
||||||
"nav" {:dispatch [::peer-nav {:cid (.-cid m) :open (keyword (.-open m))
|
|
||||||
:frame (.-frame m) :playing (boolean (.-playing m))}]}
|
|
||||||
"cursor" {:db (if (party/mirrors? (:peers db) (:peer-cid db) (.-cid m))
|
|
||||||
(assoc-in db [:cursors (.-cid m)]
|
|
||||||
{:open (keyword (.-open m)) :at (some-> (.-at m) vec)})
|
|
||||||
db)}
|
|
||||||
"delta" {:dispatch [::delta m]}
|
"delta" {:dispatch [::delta m]}
|
||||||
"access" {:dispatch [::catch-up]}
|
"access" {:dispatch [::catch-up]}
|
||||||
{})))
|
{})
|
||||||
|
m)))
|
||||||
(rf/reg-event-fx
|
|
||||||
::peer-state
|
|
||||||
(fn [{:keys [db]} [_ ^js m]]
|
|
||||||
(let [me (:peer-cid db)
|
|
||||||
cid (.-cid m)
|
|
||||||
joining (.-joining m)
|
|
||||||
db (upsert db m)
|
|
||||||
;; They followed us while we were on our own: take on the id they made
|
|
||||||
;; of our cid. Nobody hosts — we both just carry it.
|
|
||||||
adopt? (and me (= me joining) (nil? (mine db)) (followable? db))
|
|
||||||
db (cond-> db adopt? (assoc-in [:peers me :party] (.-party m)))
|
|
||||||
r (:peers db)
|
|
||||||
ours (mine db)]
|
|
||||||
(cond-> {:db db}
|
|
||||||
adopt? (assoc ::send! (state-msg db))
|
|
||||||
;; A newcomer in our party, and we drew the short straw: show them where
|
|
||||||
;; we are, rather than leave them where they were until somebody moves.
|
|
||||||
(and joining ours (= ours (party/party-of r cid)) (= me (party/responder r ours cid)))
|
|
||||||
(assoc ::nav! (nav-msg db))))))
|
|
||||||
|
|
||||||
(rf/reg-event-fx
|
|
||||||
::follow-peer
|
|
||||||
(fn [{:keys [db]} [_ cid]]
|
|
||||||
(let [me (:peer-cid db)]
|
|
||||||
(if (party/joinable? (:peers db) me cid)
|
|
||||||
(let [db (assoc-in db [:peers me :party] (party/join-id (:peers db) cid))]
|
|
||||||
{:db db ::send! (state-msg db cid)})
|
|
||||||
{}))))
|
|
||||||
|
|
||||||
(rf/reg-event-fx
|
|
||||||
::go-solo
|
|
||||||
(fn [{:keys [db]} _]
|
|
||||||
(if-let [me (:peer-cid db)]
|
|
||||||
(let [db (-> db
|
|
||||||
(assoc-in [:peers me :party] nil)
|
|
||||||
(assoc :cursors {})
|
|
||||||
(assoc-in [:party :parked] nil))]
|
|
||||||
{:db db ::send! (state-msg db)})
|
|
||||||
{})))
|
|
||||||
|
|
||||||
(rf/reg-event-fx
|
|
||||||
::set-followable
|
|
||||||
(fn [{:keys [db]} [_ on?]]
|
|
||||||
(let [db (cond-> (assoc-in db [:party :joinable] on?)
|
|
||||||
(:peer-cid db) (assoc-in [:peers (:peer-cid db) :joinable] on?))]
|
|
||||||
{:db db ::send! (state-msg db) ::remember-followable on?})))
|
|
||||||
|
|
||||||
(rf/reg-event-fx
|
|
||||||
::peer-nav
|
|
||||||
;; A party-mate moved, and we take their whole view: the tab, the frame, and
|
|
||||||
;; whether it plays — in a party anyone drives. A tab we do not have is one
|
|
||||||
;; they made a moment ago whose write is still on its way, so the move waits
|
|
||||||
;; for it (see `::remote`) rather than leaving us somewhere they are not.
|
|
||||||
(fn [{:keys [db]} [_ {:keys [cid open frame playing] :as move}]]
|
|
||||||
(cond
|
|
||||||
(not (party/mirrors? (:peers db) (:peer-cid db) cid)) {}
|
|
||||||
(not (pb/openable? db open)) {:db (assoc-in db [:party :parked] move)}
|
|
||||||
:else
|
|
||||||
(let [switch? (not= open (get-in db [:ui :open]))
|
|
||||||
db (cond-> (assoc-in db [:party :parked] nil) switch? (pb/open open))
|
|
||||||
n (pb/frames db)
|
|
||||||
f (-> (or frame 0) (max 0) (min (dec n)))
|
|
||||||
db (update db :playback assoc :frame f :playing? playing)
|
|
||||||
fps (get-in db [:clip :fps])]
|
|
||||||
{:db db
|
|
||||||
;; A new tab's sound arrives later, and `::pb/clock-ready` seeks it to
|
|
||||||
;; the frame and plays it if the db says so.
|
|
||||||
:fx (if switch?
|
|
||||||
[[::pb/pause! nil]
|
|
||||||
[::pb/clock! {:id (:clip/current db) :sid open}]]
|
|
||||||
[[::pb/seek! [fps n f]]
|
|
||||||
[(if playing ::pb/play! ::pb/pause!) nil]])}))))
|
|
||||||
|
|
||||||
(defn point!
|
|
||||||
"Our pointer on the stage, in stage pixels, or nil when it leaves — for our
|
|
||||||
party to see. Called from the pointer handler, so it is not an event: it is
|
|
||||||
sixty a second and changes nothing here."
|
|
||||||
[p]
|
|
||||||
(let [db @rf-db/app-db]
|
|
||||||
(when (party/in-party? (:peers db) (:peer-cid db))
|
|
||||||
(cursor! {:kind "cursor" :open (sid->wire (get-in db [:ui :open])) :at p}))))
|
|
||||||
|
|
||||||
(def ^:private steer
|
|
||||||
"A party moves together. When an event changes the open tab, the frame, or
|
|
||||||
whether it plays, the party hears where we are now.
|
|
||||||
|
|
||||||
NOT ON A TICK. Every member plays the same document off its own clock, so a
|
|
||||||
stream of positions would only fight them: a play goes out once, with the
|
|
||||||
frame it started from. Nor a move a mate made us make, which would only bounce
|
|
||||||
back at them — nor one made by opening another document, which is a room the
|
|
||||||
party is not in."
|
|
||||||
(rf/->interceptor
|
|
||||||
:id ::steer
|
|
||||||
:after (fn [ctx]
|
|
||||||
(let [event (first (get-in ctx [:coeffects :event]))
|
|
||||||
before (get-in ctx [:coeffects :db])
|
|
||||||
after (get-in ctx [:effects :db])
|
|
||||||
where (juxt #(get-in % [:ui :open]) #(get-in % [:playback :frame])
|
|
||||||
#(get-in % [:playback :playing?]))]
|
|
||||||
(if (or (nil? after) (#{::pb/tick ::peer-nav} event)
|
|
||||||
(= (where before) (where after))
|
|
||||||
(not= (get-in before [:project :id]) (get-in after [:project :id]))
|
|
||||||
(not (party/in-party? (:peers after) (:peer-cid after))))
|
|
||||||
ctx
|
|
||||||
(update-in ctx [:effects :fx] (fnil conj []) [::nav! (nav-msg after)]))))))
|
|
||||||
|
|
||||||
(rf/reg-sub
|
(rf/reg-sub
|
||||||
::peers
|
::peers
|
||||||
;; Everyone else in the room: our party first, then by name.
|
;; Everyone else in the room, by name.
|
||||||
(fn [db _]
|
(fn [db _]
|
||||||
(let [r (:peers db) me (:peer-cid db) mates (party/peers r me)]
|
(->> (vals (:peers db))
|
||||||
(->> (vals r)
|
(remove #(= (:cid %) (:peer-cid db)))
|
||||||
(remove #(= (:cid %) me))
|
(sort-by (juxt (comp nil? :user) :user :cid)))))
|
||||||
(map #(assoc % :mate? (contains? mates (:cid %))
|
|
||||||
:followable? (party/joinable? r me (:cid %))))
|
|
||||||
(sort-by (juxt (complement :mate?) (comp nil? :user) :user :cid))))))
|
|
||||||
|
|
||||||
(rf/reg-sub ::followable? (fn [db _] (followable? db)))
|
|
||||||
|
|
||||||
(rf/reg-sub
|
|
||||||
::cursors
|
|
||||||
;; Our party's pointers on the tab we have open.
|
|
||||||
(fn [db _]
|
|
||||||
(let [r (:peers db) mates (party/peers r (:peer-cid db)) open (get-in db [:ui :open])]
|
|
||||||
(for [[cid {at :at on :open}] (:cursors db)
|
|
||||||
:when (and at (= on open) (contains? mates cid))]
|
|
||||||
{:cid cid :at at :user (get-in r [cid :user])}))))
|
|
||||||
|
|
||||||
;; ---------------------------------------------------------------------------
|
;; ---------------------------------------------------------------------------
|
||||||
;; their writes
|
;; their writes
|
||||||
|
|
@ -500,10 +337,7 @@
|
||||||
{:seq at :status (status now synced)}))]
|
{:seq at :status (status now synced)}))]
|
||||||
(cond-> {:db db'}
|
(cond-> {:db db'}
|
||||||
(not= (:fps clip) (get-in db [:clip :fps]))
|
(not= (:fps clip) (get-in db [:clip :fps]))
|
||||||
(assoc ::pb/seek! [(:fps clip) (pb/frames db') (get-in db [:playback :frame])])
|
(assoc ::pb/seek! [(:fps clip) (pb/frames db') (get-in db [:playback :frame])])))))))
|
||||||
;; The tab a party-mate went into may be in this write.
|
|
||||||
(get-in db [:party :parked])
|
|
||||||
(assoc :dispatch [::peer-nav (get-in db [:party :parked])])))))))
|
|
||||||
|
|
||||||
(defn- ours
|
(defn- ours
|
||||||
"The clip in a delta or a document that is the one open here."
|
"The clip in a delta or a document that is the one open here."
|
||||||
|
|
@ -668,7 +502,6 @@
|
||||||
index, or a project — and answer the back button."
|
index, or a project — and answer the back button."
|
||||||
[]
|
[]
|
||||||
(rf/reg-global-interceptor follow)
|
(rf/reg-global-interceptor follow)
|
||||||
(rf/reg-global-interceptor steer)
|
|
||||||
(rf/dispatch [::who])
|
(rf/dispatch [::who])
|
||||||
(route!)
|
(route!)
|
||||||
(.addEventListener js/window "popstate" route!))
|
(.addEventListener js/window "popstate" route!))
|
||||||
|
|
|
||||||
317
frontend/src/arthur/follow.cljs
Normal file
317
frontend/src/arthur/follow.cljs
Normal file
|
|
@ -0,0 +1,317 @@
|
||||||
|
(ns arthur.follow
|
||||||
|
"Following someone: click their face and go where they go, and see each
|
||||||
|
other's pointers wherever they are — on the stage, over a button, in a list.
|
||||||
|
|
||||||
|
A LAYER, NOT A PART OF WHAT IT FOLLOWS. It reaches the rest of the app through
|
||||||
|
doors that are open anyway — the room's messages (`collab/listen!`,
|
||||||
|
`collab/say`, `collab/send!`), app-db, and the page's DOM — and it is switched
|
||||||
|
on by `install!` in `arthur.core`. Taking it out is that line, this namespace
|
||||||
|
and `follow/`, and the lines marked `follow` in `ui/share`, `app.css` and
|
||||||
|
`clips/consumers.py`.
|
||||||
|
|
||||||
|
WHAT IS FOLLOWED is a short list, `facets`, and each can be let go of on its
|
||||||
|
own from the popover beside the faces — Live Share's and Figma's answer to
|
||||||
|
wanting to look around without leaving: stay together on the tab and frame,
|
||||||
|
say, and keep your own selection. Letting go works both ways. What you do not
|
||||||
|
take from them you do not send them either, so looking around never drags the
|
||||||
|
party along.
|
||||||
|
|
||||||
|
Everyone in a party drives — see `follow/party`, tl's parties — so the moves
|
||||||
|
that go out are the deliberate ones. Every member plays the document off its
|
||||||
|
own clock, and a play goes out once with its frame rather than streamed."
|
||||||
|
(:require [arthur.events.collab :as collab]
|
||||||
|
[arthur.events.playback :as pb]
|
||||||
|
[arthur.follow.page :as page]
|
||||||
|
[arthur.follow.party :as party]
|
||||||
|
[arthur.ui.menu :as menu]
|
||||||
|
[arthur.ui.icon :as icon]
|
||||||
|
[cognitect.transit :as t]
|
||||||
|
[re-frame.core :as rf]
|
||||||
|
[re-frame.db :as rf-db]))
|
||||||
|
|
||||||
|
(def facets
|
||||||
|
"What following someone takes from them: a key, what it is called, and the
|
||||||
|
app-db paths it carries. In a path, `::open` stands for the open tab and
|
||||||
|
`::clip` for the loaded document, which is a different handle in every
|
||||||
|
browser. The two with no paths are the page's, not the db's."
|
||||||
|
[[:place "tab, frame & play" [[:ui :open] [:playback :frame] [:playback :playing?]
|
||||||
|
[:playback :rate] [:playback :loop?]
|
||||||
|
[:playback :range ::open]]]
|
||||||
|
;; So that the inspector under their pointer shows what it shows for them.
|
||||||
|
[:selection "selection" [[:ui :selection] [:ui :selections]]]
|
||||||
|
;; So that the row under their pointer is the same row.
|
||||||
|
[:rows "timeline rows" [[:ui :expanded]]]
|
||||||
|
;; Ways of looking at the stage. Each person's own until they are following
|
||||||
|
;; — and then watching someone set the onion up is how you learn it.
|
||||||
|
[:looks "onion, tracing & mat" [[:ui :onion ::clip ::open] [:ui :tracing]
|
||||||
|
[:ui :passepartout]]]
|
||||||
|
[:tools "tool & brush" [[:ui :tool] [:ui :brush] [:ui :tone] [:ui :auto-key?]]]
|
||||||
|
;; Which panes are shut, so the panel under their pointer is on screen here.
|
||||||
|
[:panels "panels" [[:ui :layout :shut]]]
|
||||||
|
[:scroll "panel scroll" nil]
|
||||||
|
[:pointers "pointers" nil]])
|
||||||
|
|
||||||
|
;; ---------------------------------------------------------------------------
|
||||||
|
;; what we keep
|
||||||
|
;;
|
||||||
|
;; `[:presence :party]` and `[:presence :joinable]` are what we tell the room;
|
||||||
|
;; `collab` says them again when the socket comes back, which is the rejoin.
|
||||||
|
;; `:follow` is ours alone: the facets let go of, a move we could not take yet
|
||||||
|
;; (`:parked`), and the last move a mate made, to catch up to on taking a facet
|
||||||
|
;; back.
|
||||||
|
|
||||||
|
(def ^:private stored {:joinable "arthur/followable" :off "arthur/follow-off"})
|
||||||
|
|
||||||
|
(defn- recall [k]
|
||||||
|
(try (.getItem js/localStorage (stored k)) (catch :default _ nil)))
|
||||||
|
|
||||||
|
(rf/reg-fx
|
||||||
|
::remember
|
||||||
|
(fn [[k v]] (try (.setItem js/localStorage (stored k) v) (catch :default _ nil))))
|
||||||
|
|
||||||
|
(defn- off [db] (get-in db [:follow :off] #{}))
|
||||||
|
|
||||||
|
(defn- me [db] (:peer-cid db))
|
||||||
|
(defn- mine [db] (party/party-of (:peers db) (me db)))
|
||||||
|
(defn- together? [db] (party/in-party? (:peers db) (me db)))
|
||||||
|
|
||||||
|
(rf/reg-event-db
|
||||||
|
::init
|
||||||
|
(fn [db _]
|
||||||
|
(-> db
|
||||||
|
(assoc-in [:presence :joinable] (not= "0" (recall :joinable)))
|
||||||
|
(assoc-in [:follow :off] (into #{} (keep keyword) (some-> (recall :off) (.split ",")))))))
|
||||||
|
|
||||||
|
;; ---------------------------------------------------------------------------
|
||||||
|
;; the view a party shares
|
||||||
|
|
||||||
|
(def ^:private writer (t/writer :json))
|
||||||
|
(def ^:private reader (t/reader :json))
|
||||||
|
|
||||||
|
(defn- paths [db]
|
||||||
|
(into [] (comp (remove (fn [[k]] (contains? (off db) k))) (mapcat last)) facets))
|
||||||
|
|
||||||
|
(defn- at
|
||||||
|
"Path template `p` in `db`."
|
||||||
|
[db p]
|
||||||
|
(mapv #(case % ::open (get-in db [:ui :open]) ::clip (:clip/current db) %) p))
|
||||||
|
|
||||||
|
(defn- view
|
||||||
|
"The part of `db` a party shares, as far as we are following — or as far as
|
||||||
|
`along` says, so that letting go of a facet is not itself a move."
|
||||||
|
([db] (view db (paths db)))
|
||||||
|
([db along] (into {} (map (juxt identity #(get-in db (at db %)))) along)))
|
||||||
|
|
||||||
|
(defn- view-msg
|
||||||
|
"A move, and the tab it was made on whether or not it moves us there: a
|
||||||
|
selection, a row or a mark only means something on its own tab."
|
||||||
|
[db]
|
||||||
|
{:kind "nav" :view (t/write writer (assoc (view db) ::tab (get-in db [:ui :open])))})
|
||||||
|
|
||||||
|
(rf/reg-fx ::nav! (page/every 120 collab/send!))
|
||||||
|
|
||||||
|
(rf/reg-event-fx
|
||||||
|
::moved
|
||||||
|
;; A mate moved, and we take what we follow of it. A tab we do not have is one
|
||||||
|
;; they made a moment ago whose write is still on its way, so the move waits for
|
||||||
|
;; it (see `steer`) rather than leaving us somewhere they are not. The rest is
|
||||||
|
;; taken only on the tab it was made on.
|
||||||
|
(fn [{:keys [db]} [_ cid v]]
|
||||||
|
(let [open (get v [:ui :open])
|
||||||
|
place? (and (contains? v [:ui :open]) (not (contains? (off db) :place)))
|
||||||
|
taken (select-keys v (remove #{[:ui :open]} (paths db)))]
|
||||||
|
(cond
|
||||||
|
(not (party/mirrors? (:peers db) (me db) cid)) {}
|
||||||
|
(and place? (not (pb/openable? db open)))
|
||||||
|
{:db (update db :follow assoc :parked [cid v] :last [cid v])}
|
||||||
|
:else
|
||||||
|
(let [switch? (and place? (not= open (get-in db [:ui :open])))
|
||||||
|
db (cond-> (update db :follow assoc :parked nil :last [cid v])
|
||||||
|
switch? (pb/open open))
|
||||||
|
db (cond-> db
|
||||||
|
(= (get v ::tab) (get-in db [:ui :open]))
|
||||||
|
(as-> db (reduce-kv #(assoc-in %1 (at %1 %2) %3) db taken)))
|
||||||
|
n (pb/frames db)
|
||||||
|
f (-> (get-in db [:playback :frame] 0) (max 0) (min (dec n)))
|
||||||
|
db (assoc-in db [:playback :frame] f)]
|
||||||
|
{:db db
|
||||||
|
;; A new tab's sound arrives later, and `::pb/clock-ready` seeks it to
|
||||||
|
;; the frame, sets its rate and plays it if the db says so.
|
||||||
|
:fx (when place?
|
||||||
|
(if switch?
|
||||||
|
[[::pb/pause! nil]
|
||||||
|
[::pb/clock! {:id (:clip/current db) :sid open}]]
|
||||||
|
[[::pb/rate! (get-in db [:playback :rate] 1.0)]
|
||||||
|
[::pb/loop! (boolean (get-in db [:playback :loop?]))]
|
||||||
|
[::pb/seek! [(get-in db [:clip :fps]) n f]]
|
||||||
|
[(if (get-in db [:playback :playing?]) ::pb/play! ::pb/pause!) nil]]))})))))
|
||||||
|
|
||||||
|
(def ^:private steer
|
||||||
|
"When an event changes what a party shares, the party hears where we are now.
|
||||||
|
|
||||||
|
NOT ON A TICK, nor a move a mate made us make, which would only bounce back
|
||||||
|
at them — nor one made by opening another document, which is a room the party
|
||||||
|
is not in. And a move a mate made before its tab reached us is taken as soon
|
||||||
|
as the write that brings it does."
|
||||||
|
(rf/->interceptor
|
||||||
|
:id ::steer
|
||||||
|
:after (fn [ctx]
|
||||||
|
(let [event (first (get-in ctx [:coeffects :event]))
|
||||||
|
before (get-in ctx [:coeffects :db])
|
||||||
|
after (get-in ctx [:effects :db])
|
||||||
|
[_ v :as parked] (get-in after [:follow :parked])]
|
||||||
|
(cond-> ctx
|
||||||
|
(and parked (pb/openable? after (get v [:ui :open])))
|
||||||
|
(update-in [:effects :fx] (fnil conj []) [:dispatch (into [::moved] parked)])
|
||||||
|
|
||||||
|
(not (or (nil? after) (#{::pb/tick ::moved} event)
|
||||||
|
(= (view before (paths after)) (view after))
|
||||||
|
(not= (get-in before [:project :id]) (get-in after [:project :id]))
|
||||||
|
(not (together? after))))
|
||||||
|
(update-in [:effects :fx] (fnil conj []) [::nav! (view-msg after)]))))))
|
||||||
|
|
||||||
|
;; ---------------------------------------------------------------------------
|
||||||
|
;; the room
|
||||||
|
|
||||||
|
(defn- wire-sid [sid] (some-> sid str (subs 1)))
|
||||||
|
|
||||||
|
(defn- who [db cid]
|
||||||
|
{:who (or (get-in db [:peers cid :user]) "guest") :colour (collab/colour cid)})
|
||||||
|
|
||||||
|
(rf/reg-fx ::point (fn [[cid who m]] (page/seen! cid who m)))
|
||||||
|
(rf/reg-fx ::scroll (fn [m] (page/scrolled! m)))
|
||||||
|
(rf/reg-fx ::forget (fn [cid] (if (= :all cid) (page/clear!) (page/gone! cid))))
|
||||||
|
|
||||||
|
(rf/reg-event-fx
|
||||||
|
::heard
|
||||||
|
(fn [{:keys [db]} [_ ^js m]]
|
||||||
|
(let [cid (.-cid m)
|
||||||
|
mate (party/mirrors? (:peers db) (me db) cid)]
|
||||||
|
(case (.-kind m)
|
||||||
|
"reset" {:db (cond-> (assoc-in db [:follow :parked] nil)
|
||||||
|
(.-elsewhere m) (update :presence dissoc :party))
|
||||||
|
::forget :all}
|
||||||
|
"leave" {::forget cid}
|
||||||
|
"state" (let [joining (.-joining m)
|
||||||
|
;; They followed us while we were on our own: take on the
|
||||||
|
;; id they made of our cid. Nobody hosts — we both carry it.
|
||||||
|
adopt? (and (me db) (= (me db) joining) (nil? (mine db))
|
||||||
|
(get-in db [:presence :joinable]))
|
||||||
|
fx (if adopt? (collab/say db {:party (.-party m)}) {:db db})
|
||||||
|
db (:db fx)
|
||||||
|
r (:peers db)
|
||||||
|
ours (mine db)]
|
||||||
|
(cond-> fx
|
||||||
|
(not (party/mirrors? r (me db) cid)) (assoc ::forget cid)
|
||||||
|
;; A newcomer in our party, and we drew the short straw: show
|
||||||
|
;; them where we are, rather than leave them where they were
|
||||||
|
;; until somebody moves.
|
||||||
|
(and joining ours (= ours (party/party-of r cid))
|
||||||
|
(= (me db) (party/responder r ours cid)))
|
||||||
|
(assoc ::nav! (view-msg db))))
|
||||||
|
"nav" {:dispatch [::moved cid (t/read reader (.-view m))]}
|
||||||
|
"cursor" (if (and mate (not (contains? (off db) :pointers))
|
||||||
|
(= (.-open m) (wire-sid (get-in db [:ui :open]))))
|
||||||
|
{::point [cid (who db cid) (js->clj m :keywordize-keys true)]}
|
||||||
|
{::forget cid})
|
||||||
|
"scroll" (if (and mate (not (contains? (off db) :scroll)))
|
||||||
|
{::scroll (js->clj m :keywordize-keys true)}
|
||||||
|
{})
|
||||||
|
{}))))
|
||||||
|
|
||||||
|
;; ---------------------------------------------------------------------------
|
||||||
|
;; what you do
|
||||||
|
|
||||||
|
(rf/reg-event-fx
|
||||||
|
::follow
|
||||||
|
(fn [{:keys [db]} [_ cid]]
|
||||||
|
(if (party/joinable? (:peers db) (me db) cid)
|
||||||
|
(collab/say db {:party (party/join-id (:peers db) cid)} {:joining cid})
|
||||||
|
{})))
|
||||||
|
|
||||||
|
(rf/reg-event-fx
|
||||||
|
::leave
|
||||||
|
(fn [{:keys [db]} _]
|
||||||
|
(-> (collab/say (update db :follow dissoc :parked :last) {:party nil})
|
||||||
|
(assoc ::forget :all))))
|
||||||
|
|
||||||
|
(rf/reg-event-fx
|
||||||
|
::set-joinable
|
||||||
|
(fn [{:keys [db]} [_ on?]]
|
||||||
|
(assoc (collab/say db {:joinable on?}) ::remember [:joinable (if on? "1" "0")])))
|
||||||
|
|
||||||
|
(rf/reg-event-fx
|
||||||
|
::toggle
|
||||||
|
;; Taking a facet back catches up to where the party last was.
|
||||||
|
(fn [{:keys [db]} [_ k]]
|
||||||
|
(let [was (off db)
|
||||||
|
now (if (contains? was k) (disj was k) (conj was k))
|
||||||
|
db (assoc-in db [:follow :off] now)]
|
||||||
|
(cond-> {:db db ::remember [:off (.join (to-array (map name now)) ",")]}
|
||||||
|
(= :pointers k) (assoc ::forget :all)
|
||||||
|
(and (contains? was k) (get-in db [:follow :last]))
|
||||||
|
(assoc :dispatch (into [::moved] (get-in db [:follow :last])))))))
|
||||||
|
|
||||||
|
(rf/reg-sub ::joinable? (fn [db _] (get-in db [:presence :joinable] true)))
|
||||||
|
(rf/reg-sub ::together? (fn [db _] (together? db)))
|
||||||
|
(rf/reg-sub ::off (fn [db _] (off db)))
|
||||||
|
(rf/reg-sub ::mates (fn [db _] (party/peers (:peers db) (me db))))
|
||||||
|
(rf/reg-sub ::may? (fn [db [_ cid]] (party/joinable? (:peers db) (me db) cid)))
|
||||||
|
|
||||||
|
(defn face
|
||||||
|
"What following adds to a face in the roster: it is the whole control —
|
||||||
|
follow them, or, once you are together, leave, which is the same one click."
|
||||||
|
[{:keys [cid user]}]
|
||||||
|
(let [who (or user "guest")
|
||||||
|
mate? (contains? @(rf/subscribe [::mates]) cid)
|
||||||
|
may? @(rf/subscribe [::may? cid])]
|
||||||
|
{:class (when mate? "mate")
|
||||||
|
:disabled (not (or mate? may?))
|
||||||
|
:title (cond mate? (str "following " who " — click to stop")
|
||||||
|
may? (str "follow " who)
|
||||||
|
:else (str who " isn't letting anyone follow"))
|
||||||
|
:on-click #(rf/dispatch (if mate? [::leave] [::follow cid]))}))
|
||||||
|
|
||||||
|
(defn controls
|
||||||
|
"The eye — whether others may follow you — and, while you are together, what
|
||||||
|
you follow of them, each a switch."
|
||||||
|
[]
|
||||||
|
(let [open? @(rf/subscribe [::joinable?])
|
||||||
|
off @(rf/subscribe [::off])]
|
||||||
|
[:<>
|
||||||
|
[:button.followable {:class (when open? "on")
|
||||||
|
:aria-label "let others follow me"
|
||||||
|
:title (if open?
|
||||||
|
"others can follow you — click to stop them"
|
||||||
|
"nobody can follow you — click to let them")
|
||||||
|
:on-click #(rf/dispatch [::set-joinable (not open?)])}
|
||||||
|
[icon/view :eye]]
|
||||||
|
(when @(rf/subscribe [::together?])
|
||||||
|
[menu/popover {:label "▾" :title "what you follow" :class "follow-what"}
|
||||||
|
(fn [_]
|
||||||
|
[:div.view-popout
|
||||||
|
(for [[k label] facets]
|
||||||
|
^{:key k}
|
||||||
|
[:label [:input {:type "checkbox" :checked (not (contains? off k))
|
||||||
|
:on-change #(rf/dispatch [::toggle k])}]
|
||||||
|
label])
|
||||||
|
[:small "Unticked, you look around on your own — and don't move them either."]])])]))
|
||||||
|
|
||||||
|
;; ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
(defn- sharing
|
||||||
|
"What the page layer sends right now, or nil when there is nobody to send it
|
||||||
|
to. Read off app-db rather than subscribed: it is asked on a pointer move."
|
||||||
|
[]
|
||||||
|
(let [db @rf-db/app-db]
|
||||||
|
(when (together? db)
|
||||||
|
{:open (wire-sid (get-in db [:ui :open]))
|
||||||
|
:scroll? (not (contains? (off db) :scroll))})))
|
||||||
|
|
||||||
|
(defn install!
|
||||||
|
"Follow from now on. The one line in `arthur.core`."
|
||||||
|
[]
|
||||||
|
(rf/dispatch-sync [::init])
|
||||||
|
(rf/reg-global-interceptor steer)
|
||||||
|
(collab/listen! ::heard)
|
||||||
|
(page/install! {:send! collab/send! :sharing sharing}))
|
||||||
250
frontend/src/arthur/follow/page.cljs
Normal file
250
frontend/src/arthur/follow/page.cljs
Normal file
|
|
@ -0,0 +1,250 @@
|
||||||
|
(ns arthur.follow.page
|
||||||
|
"A party's pointers and panel scroll, anywhere on the page.
|
||||||
|
|
||||||
|
A POINTER IS WHAT IT POINTS AT, NOT WHERE IT IS. Two windows are never laid
|
||||||
|
out alike — another size, a pane dragged wider, the stage zoomed — so a pixel
|
||||||
|
lands on something else. What goes out instead is the element under the
|
||||||
|
pointer, as a path down from <body>, and where it is inside each element
|
||||||
|
along the way; a mate finds the same element on their page and puts the
|
||||||
|
pointer at the same place in it. Over a button, it is over their button.
|
||||||
|
Google Docs anchors a caret to the text rather than to the screen, and
|
||||||
|
Liveblocks recommends this for cursors on a responsive page; this is that,
|
||||||
|
for a page of panels.
|
||||||
|
|
||||||
|
IN AN SVG — the stage, the timeline's curves — the point is in the SVG's own
|
||||||
|
units instead, so a pointer on the drawing stays on the drawing at any zoom
|
||||||
|
and scroll.
|
||||||
|
|
||||||
|
A path that only partly resolves — a menu open there and not here — falls
|
||||||
|
back to the deepest element both pages have, and the pointer shows dimmed.
|
||||||
|
One scrolled out of a pane waits at its edge.
|
||||||
|
|
||||||
|
Plain DOM and no React: drawn once a frame, and only while one is showing.")
|
||||||
|
|
||||||
|
;; ---------------------------------------------------------------------------
|
||||||
|
;; addresses
|
||||||
|
|
||||||
|
(defn- classes [^js el] (.getAttribute el "class"))
|
||||||
|
(defn- kind [^js el] [(.-localName el) (.. el -classList (item 0))])
|
||||||
|
|
||||||
|
(defn- nth-like
|
||||||
|
"Which of `el`'s siblings that `same?` says are like it, it is."
|
||||||
|
[^js el same?]
|
||||||
|
(count (take-while #(not (identical? % el))
|
||||||
|
(filter same? (array-seq (.. el -parentElement -children))))))
|
||||||
|
|
||||||
|
(defn- step
|
||||||
|
"`el` as one step of a path: its tag and classes, which of its siblings with
|
||||||
|
those it is, and which of those with its tag and FIRST class. The pool and the
|
||||||
|
inspector are both a `section.pane`, so the first class alone takes one for
|
||||||
|
the other whenever a pane is shut on one page and not the other; but the rest
|
||||||
|
come and go with state — `on`, `selected` — and a row lit on one page is still
|
||||||
|
the same row on the other, so that is what a step falls back to."
|
||||||
|
[^js el]
|
||||||
|
(let [tag (.-localName el) cls (classes el) k (kind el)]
|
||||||
|
[tag cls
|
||||||
|
(nth-like el #(and (= tag (.-localName %)) (= cls (classes %))))
|
||||||
|
(nth-like el #(= k (kind %)))]))
|
||||||
|
|
||||||
|
(defn- child [^js parent [tag cls n m]]
|
||||||
|
(let [kids (array-seq (.-children parent))
|
||||||
|
k [tag (not-empty (first (some-> cls (.split " "))))]]
|
||||||
|
(or (nth (filter #(and (= tag (.-localName %)) (= cls (classes %))) kids) n nil)
|
||||||
|
(nth (filter #(= k (kind %)) kids) m nil))))
|
||||||
|
|
||||||
|
(defn- lineage
|
||||||
|
"The elements from below <body> down to `el`."
|
||||||
|
[^js el]
|
||||||
|
(->> (iterate #(.-parentElement ^js %) el)
|
||||||
|
(take-while #(and % (not (identical? % js/document.body))))
|
||||||
|
reverse))
|
||||||
|
|
||||||
|
(defn- svg-root [^js el]
|
||||||
|
(when (instance? js/SVGElement el)
|
||||||
|
(last (take-while some? (iterate #(.-ownerSVGElement ^js %) el)))))
|
||||||
|
|
||||||
|
(defn- round [x] (/ (js/Math.round (* 1000 x)) 1000))
|
||||||
|
|
||||||
|
(defn- through [^js svg m x y]
|
||||||
|
(let [p (.matrixTransform (js/DOMPoint. x y) m)] [(round (.-x p)) (round (.-y p))]))
|
||||||
|
|
||||||
|
(defn- address
|
||||||
|
"Where client point `x` `y` is, as a mate's page can find it."
|
||||||
|
[x y]
|
||||||
|
(when-let [hit (.elementFromPoint js/document x y)]
|
||||||
|
(let [svg (svg-root hit)
|
||||||
|
els (lineage (or svg hit))]
|
||||||
|
{:path (mapv step els)
|
||||||
|
:at (mapv (fn [^js e]
|
||||||
|
(let [r (.getBoundingClientRect e)]
|
||||||
|
[(round (/ (- x (.-left r)) (max 1 (.-width r))))
|
||||||
|
(round (/ (- y (.-top r)) (max 1 (.-height r))))]))
|
||||||
|
els)
|
||||||
|
:page [(round (/ x (.-innerWidth js/window))) (round (/ y (.-innerHeight js/window)))]
|
||||||
|
:svg (some-> svg .getScreenCTM .inverse (as-> m (through svg m x y)))})))
|
||||||
|
|
||||||
|
(defn- find-path
|
||||||
|
"The elements `path` names on this page, <body> first, as deep as they go."
|
||||||
|
[path]
|
||||||
|
(reduce (fn [found s]
|
||||||
|
(if-let [c (child (peek found) s)] (conj found c) (reduced found)))
|
||||||
|
[js/document.body] path))
|
||||||
|
|
||||||
|
;; ---------------------------------------------------------------------------
|
||||||
|
;; drawing them
|
||||||
|
|
||||||
|
(defonce ^:private shown (atom {})) ; cid → {:msg :found :clip :xy :el}
|
||||||
|
(defonce ^:private raf (atom nil))
|
||||||
|
|
||||||
|
(defn- layer []
|
||||||
|
(or (.getElementById js/document "follow-layer")
|
||||||
|
(doto (.createElement js/document "div")
|
||||||
|
(set! -id "follow-layer")
|
||||||
|
(->> (.appendChild js/document.body)))))
|
||||||
|
|
||||||
|
(defn- arrow [{:keys [who colour]}]
|
||||||
|
(doto (.createElement js/document "div")
|
||||||
|
(set! -className "follow-pointer")
|
||||||
|
(-> .-style (.setProperty "--who" colour))
|
||||||
|
(set! -innerHTML (str "<i></i><svg viewBox='0 0 11 15'>"
|
||||||
|
"<path d='M.5 .5V13.5L3.9 10.4 6.1 15.1 8.1 14.2 5.9 9.6H10.5z'/></svg>"
|
||||||
|
"<span></span>"))
|
||||||
|
(-> (.querySelector "span") (set! -textContent who))
|
||||||
|
(->> (.appendChild (layer)))))
|
||||||
|
|
||||||
|
(defn- clips
|
||||||
|
"The ancestors of the last of `found` that cut off what overflows them."
|
||||||
|
[found]
|
||||||
|
(filter #(not= "visible" (.-overflow (js/getComputedStyle %))) (rest (pop found))))
|
||||||
|
|
||||||
|
(defn- resolved [{:keys [path] :as m}]
|
||||||
|
(let [found (find-path path)] (assoc m :found found :clip (clips found))))
|
||||||
|
|
||||||
|
(defn- target
|
||||||
|
"Where a pointer goes on this page, and whether it is lost (only part of its
|
||||||
|
path is here) or away (scrolled out of view, so held at the edge)."
|
||||||
|
[{:keys [path at page svg found clip]}]
|
||||||
|
(let [d (dec (count found))
|
||||||
|
^js el (peek found)
|
||||||
|
[x y] (cond
|
||||||
|
(and svg (= d (count path)))
|
||||||
|
(if-let [m (.getScreenCTM el)] (through el m (svg 0) (svg 1)) [-99 -99])
|
||||||
|
(pos? d)
|
||||||
|
(let [r (.getBoundingClientRect el) [fx fy] (nth at (dec d))]
|
||||||
|
[(+ (.-left r) (* fx (.-width r))) (+ (.-top r) (* fy (.-height r)))])
|
||||||
|
:else [(* (page 0) (.-innerWidth js/window)) (* (page 1) (.-innerHeight js/window))])
|
||||||
|
[l t r b] (reduce (fn [[l t r b] ^js c]
|
||||||
|
(let [q (.getBoundingClientRect c)]
|
||||||
|
[(max l (.-left q)) (max t (.-top q))
|
||||||
|
(min r (.-right q)) (min b (.-bottom q))]))
|
||||||
|
[0 0 (.-innerWidth js/window) (.-innerHeight js/window)] clip)
|
||||||
|
cx (max l (min r x)) cy (max t (min b y))]
|
||||||
|
{:xy [cx cy] :lost? (< d (count path)) :away? (not= [x y] [cx cy])}))
|
||||||
|
|
||||||
|
(defn- frame! [_]
|
||||||
|
(doseq [[cid {:keys [found xy ^js el] :as s}] @shown]
|
||||||
|
(let [s (cond-> s (not (.-isConnected ^js (peek found))) resolved)
|
||||||
|
{[tx ty] :xy :keys [lost? away?]} (target s)
|
||||||
|
;; Halfway there each frame: messages come every 40ms, frames every
|
||||||
|
;; 16, and a pointer that jumps between them looks like it stutters.
|
||||||
|
[x y] (if xy [(+ (xy 0) (* 0.5 (- tx (xy 0)))) (+ (xy 1) (* 0.5 (- ty (xy 1))))] [tx ty])]
|
||||||
|
(set! (.. el -style -transform) (str "translate(" x "px," y "px)"))
|
||||||
|
(.toggle (.-classList el) "lost" lost?)
|
||||||
|
(.toggle (.-classList el) "away" away?)
|
||||||
|
(swap! shown assoc cid (assoc s :xy [x y]))))
|
||||||
|
(reset! raf (when (seq @shown) (js/requestAnimationFrame frame!))))
|
||||||
|
|
||||||
|
(defn gone! [cid]
|
||||||
|
(some-> (get-in @shown [cid :el]) .remove)
|
||||||
|
(swap! shown dissoc cid))
|
||||||
|
|
||||||
|
(defn clear! [] (run! gone! (keys @shown)))
|
||||||
|
|
||||||
|
(defn seen!
|
||||||
|
"A mate's pointer message, `{:path :at :page :svg :clicks}` — or no path,
|
||||||
|
when it has left their window."
|
||||||
|
[cid who {:keys [path clicks] :as m}]
|
||||||
|
(if-not path
|
||||||
|
(gone! cid)
|
||||||
|
(let [was (get @shown cid)
|
||||||
|
el (or (:el was) (arrow who))]
|
||||||
|
;; A press, as a ring: the one thing you cannot tell from the pointer alone.
|
||||||
|
(when (and was (not= clicks (get-in was [:msg :clicks])))
|
||||||
|
(.animate (.querySelector el "i")
|
||||||
|
#js [#js {:transform "scale(.3)" :opacity 1} #js {:transform "scale(1.6)" :opacity 0}]
|
||||||
|
450))
|
||||||
|
(swap! shown assoc cid (-> (resolved m) (assoc :msg m :el el :xy (:xy was))))
|
||||||
|
(when-not @raf (reset! raf (js/requestAnimationFrame frame!))))))
|
||||||
|
|
||||||
|
;; ---------------------------------------------------------------------------
|
||||||
|
;; scroll
|
||||||
|
|
||||||
|
(defonce ^:private applied (js/WeakMap.))
|
||||||
|
|
||||||
|
(defn- scrolled-to [^js el] [(.-scrollTop el) (.-scrollLeft el)])
|
||||||
|
|
||||||
|
(defn scrolled!
|
||||||
|
"A mate scrolled a panel. Only on a whole path: half a path is some other
|
||||||
|
panel. In pixels, because a list's rows are the same height on both pages."
|
||||||
|
[{:keys [path top left]}]
|
||||||
|
(let [found (find-path path)]
|
||||||
|
(when (= (count found) (inc (count path)))
|
||||||
|
(let [^js el (peek found)]
|
||||||
|
(set! (.-scrollTop el) top)
|
||||||
|
(set! (.-scrollLeft el) left)
|
||||||
|
(.set applied el (scrolled-to el))))))
|
||||||
|
|
||||||
|
;; ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
(defn every
|
||||||
|
"`f` with the latest arguments, at most once every `gap` ms: the first at
|
||||||
|
once, and the last always, so a mate sees where a move ENDED."
|
||||||
|
[gap f]
|
||||||
|
(let [timer (atom nil) pending (atom nil)]
|
||||||
|
(fn [& args]
|
||||||
|
(reset! pending args)
|
||||||
|
(when-not @timer
|
||||||
|
(apply f args)
|
||||||
|
(reset! pending nil)
|
||||||
|
(reset! timer (js/setTimeout (fn self []
|
||||||
|
(if-let [a @pending]
|
||||||
|
(do (reset! pending nil) (apply f a)
|
||||||
|
(reset! timer (js/setTimeout self gap)))
|
||||||
|
(reset! timer nil)))
|
||||||
|
gap))))))
|
||||||
|
|
||||||
|
(defonce ^:private installed? (atom false))
|
||||||
|
|
||||||
|
(defn install!
|
||||||
|
"Watch the page for a party: `sharing` says whether there is one, and what
|
||||||
|
tab we are on; `send!` tells it."
|
||||||
|
[{:keys [send! sharing]}]
|
||||||
|
(when-not @installed?
|
||||||
|
(reset! installed? true)
|
||||||
|
(let [clicks (atom 0)
|
||||||
|
point! (every 40 (fn [x y]
|
||||||
|
(when-let [{:keys [open]} (sharing)]
|
||||||
|
(send! (merge {:kind "cursor" :open open :clicks @clicks}
|
||||||
|
(when x (address x y)))))))
|
||||||
|
scroll! (every 60 (fn [^js el]
|
||||||
|
(when (:scroll? (sharing))
|
||||||
|
(let [[top left] (scrolled-to el)]
|
||||||
|
(send! {:kind "scroll" :path (mapv step (lineage el))
|
||||||
|
:top top :left left})))))
|
||||||
|
on (fn [target kind f] (.addEventListener target kind f #js {:capture true :passive true}))]
|
||||||
|
(on js/document "pointermove" (fn [^js e] (when (.-isPrimary e) (point! (.-clientX e) (.-clientY e)))))
|
||||||
|
(on js/document "pointerdown" (fn [^js e]
|
||||||
|
(when (.-isPrimary e)
|
||||||
|
(swap! clicks inc)
|
||||||
|
(point! (.-clientX e) (.-clientY e)))))
|
||||||
|
(on js/document.documentElement "mouseleave" (fn [_] (point! nil nil)))
|
||||||
|
(on js/document "visibilitychange" (fn [_] (when (.-hidden js/document) (point! nil nil))))
|
||||||
|
(on js/document "scroll"
|
||||||
|
(fn [^js e]
|
||||||
|
(let [el (.-target e)]
|
||||||
|
;; Not the stage's: how far in it is scrolled depends on its zoom,
|
||||||
|
;; which is each person's own. A pointer on it is in stage units.
|
||||||
|
(when (and (instance? js/Element el) (not (.closest el ".stage-area")))
|
||||||
|
(if (= (.get applied el) (scrolled-to el))
|
||||||
|
(.delete applied el) ; ours, from a mate's
|
||||||
|
(scroll! el)))))))))
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
(ns arthur.domain.party
|
(ns arthur.follow.party
|
||||||
"Following someone, worked out from the presence roster. tl's parties, nearly
|
"Following someone, worked out from the presence roster. tl's parties, nearly
|
||||||
line for line.
|
line for line.
|
||||||
|
|
||||||
|
|
@ -1,16 +1,15 @@
|
||||||
(ns arthur.ui.share
|
(ns arthur.ui.share
|
||||||
"Who is here, who may write, and who you are: the top bar's right-hand end.
|
"Who is here, who may write, and who you are: the top bar's right-hand end.
|
||||||
|
|
||||||
A face is how you follow someone: click it and you go where they go — the tab
|
A face is also how you follow someone — see `arthur.follow`, whose lines here
|
||||||
they open, the frame they are on, play when they play — and they see your
|
are marked.
|
||||||
pointer as you see theirs. See `arthur.domain.party`.
|
|
||||||
|
|
||||||
The same drop-down as `openmenu` — a button, a scrim, a panel — because these
|
The same drop-down as `openmenu` — a button, a scrim, a panel — because these
|
||||||
are the same kind of thing: a few rows about the document, gone on the next
|
are the same kind of thing: a few rows about the document, gone on the next
|
||||||
click."
|
click."
|
||||||
(:require [arthur.events.collab :as collab]
|
(:require [arthur.events.collab :as collab]
|
||||||
[arthur.events.project :as project]
|
[arthur.events.project :as project]
|
||||||
[arthur.ui.icon :as icon]
|
[arthur.follow :as follow] ; follow
|
||||||
[arthur.subs.playback :as playback]
|
[arthur.subs.playback :as playback]
|
||||||
[clojure.string :as str]
|
[clojure.string :as str]
|
||||||
[re-frame.core :as rf]
|
[re-frame.core :as rf]
|
||||||
|
|
@ -27,60 +26,25 @@
|
||||||
|
|
||||||
(defn- initial [user] (str/upper-case (subs (or user "?") 0 1)))
|
(defn- initial [user] (str/upper-case (subs (or user "?") 0 1)))
|
||||||
|
|
||||||
(defn colour
|
(defn- face [{:keys [cid user] :as p}]
|
||||||
"A collaborator's colour, the same on their face and on their cursor, and the
|
(let [f (follow/face p)] ; follow
|
||||||
same in every browser that sees them: it is read off their connection id."
|
[:button.peer (merge {:style {:background (collab/colour cid)}
|
||||||
[cid]
|
:aria-label (or user "guest") :title (or user "guest")
|
||||||
(str "hsl(" (mod (reduce #(+ (* 31 %1) (.charCodeAt %2 0)) 0 cid) 360) " 60% 42%)"))
|
:disabled true}
|
||||||
|
f
|
||||||
(defn- face [{:keys [cid user mate? followable?]}]
|
{:class [(when-not user "guest") (:class f)]})
|
||||||
(let [who (or user "guest")]
|
|
||||||
[:button.peer {:class [(when-not user "guest") (when mate? "mate")]
|
|
||||||
:style {:background (colour cid)}
|
|
||||||
:disabled (not (or mate? followable?))
|
|
||||||
:aria-label who
|
|
||||||
;; A face is the whole control: follow them, or — once you
|
|
||||||
;; are together — leave, which is the same one click.
|
|
||||||
:title (cond mate? (str "following " who " — click to stop")
|
|
||||||
followable? (str "follow " who)
|
|
||||||
:else (str who " isn't letting anyone follow"))
|
|
||||||
:on-click #(rf/dispatch (if mate? [::collab/go-solo] [::collab/follow-peer cid]))}
|
|
||||||
(initial user)]))
|
(initial user)]))
|
||||||
|
|
||||||
(defn- roster []
|
(defn- roster []
|
||||||
(let [peers @(rf/subscribe [::collab/peers])
|
(let [peers @(rf/subscribe [::collab/peers])]
|
||||||
open? @(rf/subscribe [::collab/followable?])]
|
|
||||||
(when (seq peers)
|
(when (seq peers)
|
||||||
[:span.roster
|
[:span.roster
|
||||||
[:button.followable {:class (when open? "on")
|
[follow/controls] ; follow
|
||||||
:aria-label "let others follow me"
|
|
||||||
:title (if open?
|
|
||||||
"others can follow you — click to stop them"
|
|
||||||
"nobody can follow you — click to let them")
|
|
||||||
:on-click #(rf/dispatch [::collab/set-followable (not open?)])}
|
|
||||||
[icon/view :eye]]
|
|
||||||
(doall (for [p (take 5 peers)] ^{:key (:cid p)} [face p]))
|
(doall (for [p (take 5 peers)] ^{:key (:cid p)} [face p]))
|
||||||
(when (< 5 (count peers))
|
(when (< 5 (count peers))
|
||||||
[:span.dim {:title (str/join ", " (map #(or (:user %) "guest") (drop 5 peers)))}
|
[:span.dim {:title (str/join ", " (map #(or (:user %) "guest") (drop 5 peers)))}
|
||||||
(str "+" (- (count peers) 5))])])))
|
(str "+" (- (count peers) 5))])])))
|
||||||
|
|
||||||
(defn cursors
|
|
||||||
"Our party's pointers, drawn in the stage's own SVG so they sit on what they
|
|
||||||
point at however the stage is zoomed or scrolled — and scaled back by `zoom`,
|
|
||||||
so an arrow is the same size on screen at any zoom."
|
|
||||||
[zoom]
|
|
||||||
[:g.peer-cursors {:pointer-events "none"}
|
|
||||||
(doall (for [{:keys [cid at user]} @(rf/subscribe [::collab/cursors])
|
|
||||||
:let [[x y] at c (colour cid) who (or user "guest")]]
|
|
||||||
^{:key cid}
|
|
||||||
[:g {:transform (str "translate(" x " " y ") scale(" (/ 1 zoom) ")")}
|
|
||||||
[:path.arrow {:d "M0 0V13L3.4 9.9 5.6 14.6 7.6 13.7 5.4 9.1H10z" :fill c}]
|
|
||||||
;; Sized by a guess at the name's width rather than measured: a
|
|
||||||
;; tag a few pixels long or short is fine, a layout pass per move
|
|
||||||
;; is not.
|
|
||||||
[:rect {:x 9 :y 12 :rx 3 :height 14 :width (+ 10 (* 6 (count who))) :fill c}]
|
|
||||||
[:text {:x 14 :y 22} who]]))])
|
|
||||||
|
|
||||||
(defn- sharing []
|
(defn- sharing []
|
||||||
(r/with-let [open? (r/atom false)
|
(r/with-let [open? (r/atom false)
|
||||||
draft (r/atom "")]
|
draft (r/atom "")]
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@
|
||||||
[arthur.domain.paint :as paint]
|
[arthur.domain.paint :as paint]
|
||||||
[arthur.domain.pick :as pick]
|
[arthur.domain.pick :as pick]
|
||||||
[arthur.domain.symbol :as symbol]
|
[arthur.domain.symbol :as symbol]
|
||||||
[arthur.events.collab :as collab]
|
|
||||||
[arthur.events.paint :as paint-events]
|
[arthur.events.paint :as paint-events]
|
||||||
[arthur.events.ui :as ui]
|
[arthur.events.ui :as ui]
|
||||||
[arthur.footage.store :as store]
|
[arthur.footage.store :as store]
|
||||||
|
|
@ -28,7 +27,6 @@
|
||||||
[arthur.ui.drag :as drag]
|
[arthur.ui.drag :as drag]
|
||||||
[arthur.ui.layout :as layout]
|
[arthur.ui.layout :as layout]
|
||||||
[arthur.ui.player :as player]
|
[arthur.ui.player :as player]
|
||||||
[arthur.ui.share :as share]
|
|
||||||
[arthur.ui.tracing :as tracing]
|
[arthur.ui.tracing :as tracing]
|
||||||
[arthur.ui.shortcuts :as shortcuts]
|
[arthur.ui.shortcuts :as shortcuts]
|
||||||
[arthur.ui.tools :as tools]
|
[arthur.ui.tools :as tools]
|
||||||
|
|
@ -719,13 +717,12 @@
|
||||||
;; holds what is selected, then nothing.
|
;; holds what is selected, then nothing.
|
||||||
(when (and (= "Escape" (.-key event)) selected (= :select tool))
|
(when (and (= "Escape" (.-key event)) selected (= :select tool))
|
||||||
(select! ctx (pop selected))))
|
(select! ctx (pop selected))))
|
||||||
:on-pointer-leave (fn [_] (reset! pointer nil) (collab/point! nil))
|
:on-pointer-leave (fn [_] (reset! pointer nil))
|
||||||
:on-pointer-move
|
:on-pointer-move
|
||||||
(fn [^js event]
|
(fn [^js event]
|
||||||
(when (.-isPrimary event)
|
(when (.-isPrimary event)
|
||||||
(let [p (xy (.-currentTarget event) event w h)]
|
(let [p (xy (.-currentTarget event) event w h)]
|
||||||
(reset! pointer p)
|
(reset! pointer p)
|
||||||
(collab/point! p)
|
|
||||||
(cond
|
(cond
|
||||||
;; Back through the inverse of what the handle was drawn
|
;; Back through the inverse of what the handle was drawn
|
||||||
;; through, into the shape's own coordinates.
|
;; through, into the shape's own coordinates.
|
||||||
|
|
@ -773,8 +770,7 @@
|
||||||
(if (> (count placements) 1) [group-handles ctx placements] [handles ctx]))
|
(if (> (count placements) 1) [group-handles ctx placements] [handles ctx]))
|
||||||
(when pen? [points ctx draft])
|
(when pen? [points ctx draft])
|
||||||
(when pen? [draft-lines draft hover])
|
(when pen? [draft-lines draft hover])
|
||||||
(when paints? [cursor tool])
|
(when paints? [cursor tool])]))
|
||||||
[share/cursors zoom]]))
|
|
||||||
|
|
||||||
(defonce pan (atom nil))
|
(defonce pan (atom nil))
|
||||||
(defonce navigation-blur
|
(defonce navigation-blur
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
(ns arthur.domain.party-test
|
(ns arthur.follow.party-test
|
||||||
(:require [cljs.test :refer [deftest is]]
|
(:require [cljs.test :refer [deftest is]]
|
||||||
[arthur.domain.party :as party]))
|
[arthur.follow.party :as party]))
|
||||||
|
|
||||||
(defn- roster [& entries]
|
(defn- roster [& entries]
|
||||||
(into {} (map (fn [[cid p joinable]]
|
(into {} (map (fn [[cid p joinable]]
|
||||||
|
|
@ -474,16 +474,44 @@ button.peer {
|
||||||
display: inline-grid; place-items: center;
|
display: inline-grid; place-items: center;
|
||||||
background: var(--sel); color: #fff; font-size: 10px; font-weight: 600;
|
background: var(--sel); color: #fff; font-size: 10px; font-weight: 600;
|
||||||
}
|
}
|
||||||
|
button.peer:disabled { cursor: default; }
|
||||||
|
|
||||||
|
/* follow — arthur.follow. A face you can follow lights on hover, one that will
|
||||||
|
not let you is dimmed, and the ones you are following wear a ring. The eye
|
||||||
|
says whether you may be followed; ▾ beside it is what you follow. */
|
||||||
button.peer:hover:not(:disabled) { filter: brightness(1.15); }
|
button.peer:hover:not(:disabled) { filter: brightness(1.15); }
|
||||||
button.peer:disabled { opacity: .45; cursor: default; }
|
button.peer:disabled:not(.mate) { opacity: .45; }
|
||||||
button.peer.mate { outline: 1.5px solid var(--fg); outline-offset: 1px; }
|
button.peer.mate { outline: 1.5px solid var(--fg); outline-offset: 1px; }
|
||||||
button.followable { padding: 0 3px; color: var(--dim); border-color: transparent; background: none; }
|
button.followable { padding: 0 3px; color: var(--dim); border-color: transparent; background: none; }
|
||||||
button.followable.on { color: var(--fg); }
|
button.followable.on { color: var(--fg); }
|
||||||
button.followable svg { width: 12px; height: 12px; display: block; }
|
button.followable svg { width: 12px; height: 12px; display: block; }
|
||||||
|
.follow-what .view-popout { min-width: 190px; max-width: 240px; }
|
||||||
|
.follow-what .view-popout label {
|
||||||
|
display: flex; gap: 8px; align-items: center; margin: 0; padding: 3px 0;
|
||||||
|
white-space: nowrap; cursor: pointer;
|
||||||
|
}
|
||||||
|
.follow-what .view-popout input { width: auto; margin: 0; flex: none; }
|
||||||
|
.follow-what .view-popout small { display: block; margin-top: 8px; color: var(--dim); white-space: normal; }
|
||||||
|
|
||||||
/* A party-mate's pointer on the stage, in screen pixels whatever the zoom. */
|
/* A mate's pointer, over everything and catching nothing. `lost` is a pointer
|
||||||
.peer-cursors .arrow { stroke: #fff; stroke-width: 1; stroke-linejoin: round; }
|
on something this page does not have open, `away` one scrolled out of view
|
||||||
.peer-cursors text { font-size: 10px; font-weight: 600; fill: #fff; }
|
and waiting at the edge. */
|
||||||
|
#follow-layer { position: fixed; inset: 0; pointer-events: none; z-index: 2147483000; overflow: hidden; }
|
||||||
|
.follow-pointer { position: absolute; left: 0; top: 0; will-change: transform; transition: opacity .15s; }
|
||||||
|
.follow-pointer svg { width: 11px; height: 15px; display: block; overflow: visible; }
|
||||||
|
.follow-pointer path { fill: var(--who); stroke: #fff; stroke-width: 1; stroke-linejoin: round; }
|
||||||
|
.follow-pointer span {
|
||||||
|
position: absolute; left: 9px; top: 13px; white-space: nowrap;
|
||||||
|
padding: 1px 5px; border-radius: 3px; background: var(--who);
|
||||||
|
color: #fff; font: 600 10px/12px system-ui, sans-serif;
|
||||||
|
}
|
||||||
|
.follow-pointer i {
|
||||||
|
position: absolute; left: -9px; top: -9px; width: 18px; height: 18px;
|
||||||
|
border-radius: 50%; border: 2px solid var(--who); opacity: 0;
|
||||||
|
}
|
||||||
|
.follow-pointer.lost { opacity: .45; }
|
||||||
|
.follow-pointer.away { opacity: .6; }
|
||||||
|
/* end follow */
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------
|
||||||
media pool
|
media pool
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue