Prevent view transition animations on page refreshes
View transitions don't play great with page refreshes as they can make those very noticeable
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
class ApplicationController < ActionController::Base
|
||||
include Authentication, Authorization, CurrentRequest, CurrentTimezone, SetPlatform, TurboFlash, WriterAffinity
|
||||
include Authentication, Authorization, CurrentRequest, CurrentTimezone, SetPlatform, TurboFlash, ViewTransitions, WriterAffinity
|
||||
|
||||
stale_when_importmap_changes
|
||||
allow_browser versions: :modern, block: -> { render "errors/not_acceptable", layout: "error" }
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
module ViewTransitions
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
before_action :disable_view_transitions, if: :page_refresh?
|
||||
end
|
||||
|
||||
private
|
||||
def disable_view_transitions
|
||||
@disable_view_transition = true
|
||||
end
|
||||
|
||||
def page_refresh?
|
||||
request.referrer.present? && request.referrer == request.url
|
||||
end
|
||||
end
|
||||
@@ -2,7 +2,10 @@
|
||||
<%= page_title_tag %>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no, viewport-fit=cover">
|
||||
<meta name="view-transition" content="same-origin">
|
||||
|
||||
<% unless @disable_view_transition %>
|
||||
<meta name="view-transition" content="same-origin">
|
||||
<% end %>
|
||||
<meta name="color-scheme" content="light dark">
|
||||
<meta name="theme-color" content="#ffffff" media="(prefers-color-scheme: light)">
|
||||
<meta name="theme-color" content="#000000" media="(prefers-color-scheme: dark)">
|
||||
|
||||
Reference in New Issue
Block a user