Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add this context to mousewheel and touchscroll events #965

Open
jcubic opened this issue Sep 15, 2024 · 0 comments
Open

Add this context to mousewheel and touchscroll events #965

jcubic opened this issue Sep 15, 2024 · 0 comments

Comments

@jcubic
Copy link
Owner

jcubic commented Sep 15, 2024

I have an idea for a new feature for jQuery Terminal

The task is to add this context (that in source code is in self variable) to mousewheel and touchscroll and update TypeScript types for the callbacks.

This code should work:

function scroll() {
  const { length } = this.get_output().split('\n');
  const rows = term.rows();
  if (rows > length) {
    this.removeClass('shake');
    this.addClass('shake');
    this.stopTime('shake');
    this.oneTime(200, 'shake', () => {
      this.removeClass('shake');
    });
  }
}

export function initTerminal() {
  const $ = globalThis.$;
  const $term = $('.term');
  $term.empty();

  const term = $term.terminal({}, {
    mousewheel: scroll,
    touchscroll: scroll
  });

  return $term;
};

Code taken from new website (after refactoring to new API).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant