Skip to content

feat: Add swipe/scroll search engine switching#145

Merged
prem-k-r merged 6 commits into
mainfrom
engine-scrolling
Feb 15, 2026
Merged

feat: Add swipe/scroll search engine switching#145
prem-k-r merged 6 commits into
mainfrom
engine-scrolling

Conversation

@prem-k-r

@prem-k-r prem-k-r commented Feb 14, 2026

Copy link
Copy Markdown
Owner

📌 Description

Added the ability to change search engines by swiping (touch) or scrolling (mouse wheel) on the dropdown icon when search engines are hidden, with smooth vertical carousel animations.

✅ Checklist

  • I have read and followed the Contributing Guidelines.
  • My code follows the project's coding style and conventions.
  • I have tested my changes thoroughly to ensure expected behavior.
  • I have verified compatibility across Chrome and Firefox (additional browsers if applicable).
  • I have attached relevant visual evidence (screenshots/videos) if applicable.
  • I have updated the CHANGELOG.md under the appropriate categories with all my changes in this PR.

Feature Overview

Adds touch-swipe and mouse-wheel gestures on the search dropdown button to switch search engines when the dropdown is hidden, using a smooth vertical carousel animation and persisting the selected engine.

Technical Implementation

JavaScript (scripts/search.js)

  • New state, helpers and wiring:
    • State vars: engineSwipeStartY, engineSwipeEndY, isEngineSwiping, isEngineSwitching, engineSwitchTimeout, currentSearchEngineIndex.
    • Element ref: dropdownBtn ('.dropdown-btn').
    • Helpers added: getAllEngines(), getCurrentSearchEngineIndex().
  • switchEngine(direction):
    • Computes next/previous engine (no-op if <2 engines).
    • Applies 'engine-switching' class to #searchbar and sets data-switch-direction ('next'|'prev') to drive CSS animation.
    • Performs radio swap and dropdown resort roughly 180ms into the animation, persists selection to localStorage (selectedSearchEngine- and activeSearchMode), and refreshes engine hints via toggleSearchEngines(newCategory).
    • Removes animation class at ~400ms and enforces a ~400ms cooldown to throttle rapid repeats.
  • Input handlers:
    • Touch: touchstart/touchmove/touchend on .dropdown-btn to detect vertical swipes and call switchEngine('next'|'prev').
    • Wheel: wheel handler on .dropdown-btn to call switchEngine based on deltaY.
    • Handlers early-return when the dropdown is visible or when the shortcut that shows engines is active.
  • Implementation note: the swipe/scroll control block is duplicated in scripts/search.js (two identical blocks). Consolidation recommended to avoid duplicate handlers.

CSS (style.css)

  • Adds vertical carousel animations:
    • Keyframes slideUpFade and slideDownFade.
    • Styles for .searchbar.engine-switching[data-switch-direction="next"|"prev"] targeting .dropdown-btn > * to animate vertical slide + fade.
    • Minor transition wrapper adjustments for .dropdown-btn > *.
  • Selector change: .authorName → .authorWrapper in quotes/author display rules (verify this is intentional).

Manifests & Changelog

  • manifest(firefox).json and manifest.json: version bumped 3.3.5 → 3.3.6.
  • CHANGELOG.md: Unreleased entry added noting support for touch-swipe and mouse-wheel gestures on the search engine icon.

Behavior & Edge Cases

  • No action if fewer than two engines, if dropdown is open, or if the shortcut that shows engines is enabled.
  • Engine swap occurs mid-animation (~180ms) with animation completing ≈400ms.
  • 400ms cooldown prevents rapid repeated switches.
  • Verified on Chrome and Firefox; visual evidence attached where applicable.

Files & Size Impact

  • scripts/search.js: ~+122/-2 (new swipe/scroll logic; duplicate block present).
  • style.css: ~+65/-10 (animation + selector rename).
  • CHANGELOG.md: +4/-0.
  • manifest files: +1/-1 each (version bumps).

Testing & Checklist

  • Author reports testing on Chrome and Firefox; contributing guidelines and code style followed.
  • CHANGELOG.md updated in this PR.

Notes for Reviewers

  • Remove the duplicated swipe/scroll block in scripts/search.js to ensure handlers are attached once.
  • Verify throttling/cooldown logic prevents overlapping switches.
  • Confirm the .authorName → .authorWrapper selector change is intentional and does not hide unintended elements.

Add touch swipe and mouse-wheel handlers to cycle search engines from the dropdown button, with a guarded switchEngine() that updates radio selection, persists active mode to localStorage, and defers swapping for a 400ms animation (fade-out at ~180ms). CSS adds engine-switching state and slideUp/slideDown keyframes for smooth vertical carousel transitions. The feature only triggers when the shortcut switch is enabled and the dropdown is closed, and it prevents rapid repeated switches via a 400ms throttle.
@prem-k-r prem-k-r added enhancement New feature or request under-review Currently being reviewed. Please wait for feedback. ui/ux labels Feb 14, 2026
@coderabbitai

This comment was marked as resolved.

@prem-k-r prem-k-r requested a review from itz-rj-here February 14, 2026 18:07
@itz-rj-here

Copy link
Copy Markdown
Collaborator

I will check tomorrow morning 🫡

coderabbitai[bot]

This comment was marked as resolved.

Comment thread scripts/search.js Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@scripts/search.js`:
- Around line 414-420: Rename the function getcurrentSearchEngineIndex to
getCurrentSearchEngineIndex to match camelCase; inside it, call getAllEngines()
as before but guard against
document.querySelector('input[name="search-engine"]:checked') returning null by
checking selectedOption and returning -1 (or another sentinel) when it's null,
and only access selectedOption.value when non-null; update any call sites that
referenced getcurrentSearchEngineIndex to the new getCurrentSearchEngineIndex
name.
- Around line 479-485: The touchstart handler on dropdownBtn currently calls
e.preventDefault(), which suppresses the synthesized click and prevents tapping
from opening the dropdown when hideSearchWith.checked is true; update the touch
handling in the touchstart listener (for dropdownBtn) to NOT call
e.preventDefault() unconditionally — instead record engineSwipeStartY in the
touchstart handler only, and move any call to preventDefault() to touchmove or
touchend after detecting a swipe beyond your threshold (or remove it entirely)
so taps still fire their click; adjust the listener options if you no longer
need passive: false.
🧹 Nitpick comments (1)
scripts/search.js (1)

400-406: currentSearchEngineIndex doesn't need to be module-scoped.

currentSearchEngineIndex is assigned on line 429 via getcurrentSearchEngineIndex() and only used within switchEngine. It can be a local let inside switchEngine instead, eliminating unnecessary shared mutable state.

Comment thread scripts/search.js Outdated
Comment thread scripts/search.js
coderabbitai[bot]

This comment was marked as off-topic.

@itz-rj-here itz-rj-here left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working fine in both browsers with no issues

@prem-k-r prem-k-r removed the under-review Currently being reviewed. Please wait for feedback. label Feb 15, 2026
@prem-k-r prem-k-r merged commit a31c2df into main Feb 15, 2026
3 checks passed
@prem-k-r prem-k-r deleted the engine-scrolling branch February 15, 2026 09:47
@coderabbitai coderabbitai Bot mentioned this pull request Apr 9, 2026
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request ui/ux

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants